vzachin
09-23-2008, 10:44 AM
hi,
i'm copy data from sheet1 to sheet2
i'm having problem with defining a lastrow because all the cells in the range contains a formula.
when i define the last row here:iLastRw = Sheets("sheet1").Cells(endrw, "e").End(xlUp).Row
the last row is picking up the formulas in that row.
i only want to copy the rows (from column e to column j) with data in them. the rows of data will be consecutive (in other words, the rows of data will never skip).
i experience problems when i do a subsequent copy & paste in sheet2. i want to paste to the last active row +1 in sheet2 but the initial copy & paste, pasted all the rows from sheet 1.
is there a way around this?
i have to do multiple copy & paste, which is why i'm defining my rows.
here's my coding so far
Sub test1()
begrw = 13
endrw = 31
iLastRw = Sheets("sheet1").Cells(endrw, "e").End(xlUp).Row
LastRw = Sheets("sheet2").Cells(Rows.Count, "A").End(xlUp).Row
Range(("F" & begrw), ("J" & iLastRw)).Copy
Sheets("sheet2").Range("a" & LastRw + 1).PasteSpecial xlValues
Application.CutCopyMode = False
End Sub
i suppose i can write code to remove the empty rows in sheet2
thanks
zach
i'm copy data from sheet1 to sheet2
i'm having problem with defining a lastrow because all the cells in the range contains a formula.
when i define the last row here:iLastRw = Sheets("sheet1").Cells(endrw, "e").End(xlUp).Row
the last row is picking up the formulas in that row.
i only want to copy the rows (from column e to column j) with data in them. the rows of data will be consecutive (in other words, the rows of data will never skip).
i experience problems when i do a subsequent copy & paste in sheet2. i want to paste to the last active row +1 in sheet2 but the initial copy & paste, pasted all the rows from sheet 1.
is there a way around this?
i have to do multiple copy & paste, which is why i'm defining my rows.
here's my coding so far
Sub test1()
begrw = 13
endrw = 31
iLastRw = Sheets("sheet1").Cells(endrw, "e").End(xlUp).Row
LastRw = Sheets("sheet2").Cells(Rows.Count, "A").End(xlUp).Row
Range(("F" & begrw), ("J" & iLastRw)).Copy
Sheets("sheet2").Range("a" & LastRw + 1).PasteSpecial xlValues
Application.CutCopyMode = False
End Sub
i suppose i can write code to remove the empty rows in sheet2
thanks
zach