[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Improve my github hack!

Gregory Brown

10/18/2008 4:42:00 PM

I just wrote a simple (and probably dirty) hack for making it a tiny
bit easier to vendor libs found on github.

http://gist.github...

(Or if you prefer to read it through my blaag:
http://blog.majesticseacr.../archives/2008.10/...)

I'm hoping folks will help me see what I'm missing or what I could do
better by forking the gist and improving the script.
Of course, if you know of a tool that already does this, just point me there :)

-greg

--
Technical Blaag at: http://blog.majesticseacr... | Non-tech
stuff at: http://metametta.bl...

3 Answers

Joel

7/29/2009 4:40:00 PM

0

I fixed the row problem and the comma. the order can be changed to any order
you want. I gave just an example. Put in as many columns of data that you
want to move and the source and desttination column as required.

I don't know what column the dat is located so I can't help with filtering
the date automatically.

Sub DataMove()

Set SrcSht = Sheets("Sheet1")
Set DestSht = Sheets("Sheet2")

NewRow = 1
RowCount = 1

With SrcSht
Do While .Range("B" & RowCount) <> ""
Keyword = .Range("B" & RowCount)
If Keyword = "wood" Or _
Keyword = "stone" Or _
Keywood = "tile" Then

DestSht.Cells(NewRow, "H").Value = .Cells(RowCount, "A")
DestSht.Cells(NewRow, "J").Value = .Cells(RowCount, "B")
DestSht.Cells(NewRow, "K").Value = .Cells(RowCount, "C")
DestSht.Cells(NewRow, "G").Value = .Cells(RowCount, "D")
NewRow = NewRow + 1
End If
RowCount = RowCount + 1
Loop
End With
End Sub


"Jbm" wrote:

> Joel,
> Thanks for spending time helping me on this, it's much appreciated. I'm
> running into a few issues with your code though. Minorly, in case you try to
> test the code, note that there's an extra comma on New Row = New Row + 1.
> Onto the real troubles I'm having though. First, the code doesn't seem to
> want to grab the correct rows of Keywords with the "if Keyword" strings. For
> some reason the old "if c.Value Like" grabbed the right ones, but not these,
> so maybe we should use the old code on that? Another less pressing problem
> is that the new code is mixing up what order the data is in. I think I
> should have been more clear in the original description: columns A-E have
> data in them, A holds the date, B holds the name with the words we're
> searching for, and C-E have numerical data. The new code however is placing
> the data into columns in the order DA Blank BC, and E doesn't even show up.
> More important than these issues however is that the new code does pull
> specific dates, but not the ones we need. I used your code on a worksheet
> that goes up to 7/23/09, but the data pulled only consisted of dates 7/01/09
> to 7/03/09. For that sheet, for example, I am trying to get data only from
> 7/22/09.
>
> I guess I didn't realize how difficult this might be, and apologies if I
> wasn't clear at the start -- if you need more clarification to help, please
> just ask, any way I can help you, helps me. Thanks for the help again,
> though.

Jbm

7/29/2009 5:16:00 PM

0

Joel,
I'm afraid I'm being counterproductive here. Let my try to simplify this.
Don't worry about keywords for this example at all.
Imagine I have the dates in column A like this, with corresponding data in
column B

Column A
7/01/09
7/01/09
7/02/09
7/02/09
7/02/09
7/03/09
7/03/09

Now suppose the date is 7/03/09, so in this instance I need to copy rows 3-5
(data from the previous day) and place that data in Columns D and E. So
Column D would look like this

Column D
7/02/09
7/02/09
7/02/09

And Column E would have the corresponding data to those dates that was in B.
I need to do this every day, with a separate new document, so for today (the
29th), I need Column D to hold only data from the 28th. The last cell in A
will always contain the current date. I'm sorry to have wasted your effort
on the previous code, but I think this will get at what I'm trying to do with
better accuracy. Thanks.

Joel

7/29/2009 5:43:00 PM

0

I added an inport box to select the rows you want. I also added a new workbook

Sub DataMove()

Set SrcSht = Sheets("Sheet1")

Set Newbk = Workbooks.Add
Set DestSht = Newbk.Sheets("Sheet1")

SrcSht.Activate
Set MyCell = Application.InputBox( _
prompt:="Select Row to Export", _
Type:=8)

Set SrcSht = MyCell.Parent
FirstRow = MyCell.Row
LastRow = FirstRow + MyCell.Rows.Count - 1

NewRow = 1
RowCount = 1

With SrcSht
For RowCount = FirstRow To LastRow
Keyword = .Range("B" & RowCount)
If Keyword = "wood" Or _
Keyword = "stone" Or _
Keywood = "tile" Then

DestSht.Cells(NewRow, "H").Value = .Cells(RowCount, "A")
DestSht.Cells(NewRow, "J").Value = .Cells(RowCount, "B")
DestSht.Cells(NewRow, "K").Value = .Cells(RowCount, "C")
DestSht.Cells(NewRow, "G").Value = .Cells(RowCount, "D")
NewRow = NewRow + 1
End If
RowCount = RowCount + 1
Next RowCount
End With
End Sub


"Jbm" wrote:

> Joel,
> I'm afraid I'm being counterproductive here. Let my try to simplify this.
> Don't worry about keywords for this example at all.
> Imagine I have the dates in column A like this, with corresponding data in
> column B
>
> Column A
> 7/01/09
> 7/01/09
> 7/02/09
> 7/02/09
> 7/02/09
> 7/03/09
> 7/03/09
>
> Now suppose the date is 7/03/09, so in this instance I need to copy rows 3-5
> (data from the previous day) and place that data in Columns D and E. So
> Column D would look like this
>
> Column D
> 7/02/09
> 7/02/09
> 7/02/09
>
> And Column E would have the corresponding data to those dates that was in B.
> I need to do this every day, with a separate new document, so for today (the
> 29th), I need Column D to hold only data from the 28th. The last cell in A
> will always contain the current date. I'm sorry to have wasted your effort
> on the previous code, but I think this will get at what I'm trying to do with
> better accuracy. Thanks.
>