G
Guest
Tom Ogilvy provided me with this great macro in order to copy certain rows
from a spreadsheet into a new master tab. In summary, I am copying rows
7,9,10,11 then skiping 16 rows and copying 23,25,26,27, skiping 16 rows etc
down the entire sheet. For some reason, the macro is not copying row 11, 27,
etc. and I'm not sure how to modify to capture that row. Can someone explain
to me the section of the macro sh.Cells(i + 2, 1).Resize(3,1))? I presume
that is the line I would need to adjust to pick up that additional row.
Sub CopyData()
Dim i As Long, rng As Range, sh As Worksheet
Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = "Master"
Set sh = Worksheets("Input-Sales")
i = 7
Do While Not IsEmpty(sh.Cells(i, 1))
Set rng = Union(sh.Cells(i, 1), _
sh.Cells(i + 2, 1).Resize(3, 1))
rng.EntireRow.Copy Destination:= _
Worksheets("Master").Cells(Rows.Count, 1).End(xlUp)
i = i + 16
Loop
End Sub
Thanks in advance for your help. This is definitely a learning experience
for me!
Regards,
HJ
from a spreadsheet into a new master tab. In summary, I am copying rows
7,9,10,11 then skiping 16 rows and copying 23,25,26,27, skiping 16 rows etc
down the entire sheet. For some reason, the macro is not copying row 11, 27,
etc. and I'm not sure how to modify to capture that row. Can someone explain
to me the section of the macro sh.Cells(i + 2, 1).Resize(3,1))? I presume
that is the line I would need to adjust to pick up that additional row.
Sub CopyData()
Dim i As Long, rng As Range, sh As Worksheet
Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = "Master"
Set sh = Worksheets("Input-Sales")
i = 7
Do While Not IsEmpty(sh.Cells(i, 1))
Set rng = Union(sh.Cells(i, 1), _
sh.Cells(i + 2, 1).Resize(3, 1))
rng.EntireRow.Copy Destination:= _
Worksheets("Master").Cells(Rows.Count, 1).End(xlUp)
i = i + 16
Loop
End Sub
Thanks in advance for your help. This is definitely a learning experience
for me!
Regards,
HJ
