View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Charles Chickering Charles Chickering is offline
external usenet poster
 
Posts: 272
Default Looping through workbook

Sub CopyLines()
Dim wb1 as Workbook
Dim wb2 as Workbook
Dim cnt as Long
Dim lRow as Long 'Last Row

Set wb1 = Workbooks("All.xls") 'Workbook with all down times
Set wb2 = Workbooks("Summary.xls") 'Worbook with 50
lRow = wb1.Sheets("Sheet1").Range("A" & _
wb1.Sheets("Sheet1").Rows.Count).End(xlUp).Row
For cnt = 1 to lRow
If wb1.Sheets("Sheet1").Range("A" & cnt) 50 Then _
'Change "A" to the column in question
wb1.Sheets("Sheet1").Rows(cnt).Copy
wb2.Sheets("Sheet1").Rows(2).Insert Shift:=xlDown 'Assume Header Row
Application.CutCopyMode = False
End If
Next
End Sub
--
Charles Chickering

"A good example is twice the value of good advice."


"bpotter" wrote:

I have a woksheet that has around 50 lines. In one column I have
downtime for each entry. I am trying to loop though each entry looking
at the downtime and if it is greater than 50 then I want to transfer
the whole line into a special workbook. But here is the catch! I want
to move the previous day lines down as I am adding entries into the
workbook. I am not very good at macros so if you help me please dumb it
down a little. I would appreciate any help at all. Thanks in advance!!!