patsdavixen
New Member
- Joined
- Mar 5, 2013
- Messages
- 32
I'm working on this macro that copies data on sheet1 from A2:AI2 till the last non-blank row in the same range i.e. A:AI and paste it on sheet2 in the first blank row. However, my code keeps picking up A1:AI1 from sheet1 as well and pastes it on sheet2 just before the data that I actually want to paste. Here's my code:
Please help me fix it
Thanks,
Pat
Code:
Sub Copy()
Range("A2").Select
lastCol = ActiveSheet.Range("A2:AI2").End(xlToRight).Column
lastrow = ActiveSheet.Cells(65536, lastCol).End(xlUp).Row
ActiveSheet.Range("A2:AI2", ActiveSheet.Cells(lastrow, lastCol)).Copy
ActiveSheet.Next.Select
If Application.WorksheetFunction.CountA("A:A") = 0 Then
[A1].Select
Else
On Error Resume Next
Columns(1).SpecialCells(xlCellTypeBlanks)(1, 1).Select
If Err <> 0 Then
On Error GoTo 0
[A65536].End(xlUp)(2, 1).Select
End If
On Error GoTo 0
End If
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
Please help me fix it
Thanks,
Pat