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
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
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:
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.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
HTH,
Ken Puls, CMA - Microsoft MVP (Excel)
I hate it when my computer does what I tell it to, and not what I want it to.
Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar
This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!
Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!
Thanks for the solution, works like a charm!
jawsm
jawsm: Please mark solved by clicking on Thread Tools dropdown at the top of the thread.
Thanks! Glad you got it resolved!
~Anne Troy
Hi jawsm!
Glad you got it solved! I'll take care of marking this one solved.
Ken Puls, CMA - Microsoft MVP (Excel)
I hate it when my computer does what I tell it to, and not what I want it to.
Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar
This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!
Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!