PDA

View Full Version : [SOLVED] Copy Rows to Another Sheet Macro



jawsm
03-24-2005, 01:46 PM
How to copy from worksheet1 only rows with data to worksheet2. In both worksheets the first 2 rows contain headers. The headers should not be copied to worksheet2. Please solve using macro code

Thanks in advance!

jawsm

Ken Puls
03-24-2005, 02:03 PM
Hi there,

Welcome to VBAX!

Providing that there is always data in column A (no rows that have a blank in A, but data in another column), try this:


Sub copy()
Dim i As Long, t As Long
For i = 3 To ActiveSheet.Range("A65536").End(xlUp).Row
If Application.WorksheetFunction.CountA(Range("A" & i & ":IV" & i)) > 0 Then
t = t + 1
Range("A" & i).EntireRow.copy Worksheets("Sheet2").Range("A" & t)
End If
Next i
End Sub

It will skip your headings, and then paste each row starting at A1 on Sheet2. (You may have to update "Sheet2" to the name of your worksheet if it is different.

HTH,

jawsm
03-25-2005, 04:24 AM
Thanks for the solution, works like a charm!

jawsm

Anne Troy
03-25-2005, 05:50 AM
jawsm: Please mark solved by clicking on Thread Tools dropdown at the top of the thread.

Thanks! Glad you got it resolved!

Ken Puls
03-25-2005, 09:37 AM
Hi jawsm!

Glad you got it solved! :yes I'll take care of marking this one solved. ;)