Hi, my first post so be gentle with me!
I have a macro that copy and pastes data from sheet 3 after i have an external system report populate sheet 3 with data. There are 4 reports that run in a chain and if one doesnt find any data to export to sheet 3 the macro throws up a debug error stopping my report from running
So what i need to add to this macro is a type of error do message to continue and not error if it cant find anything to copy and paste.
The Macro is...
Sub APPENDDATA()
ActiveWorkbook.Sheets("Data").Select
Dim N As Long
N = Cells(1, 1).End(xlDown).Row
Set DT = Range("A1:Y" & N)
DT.Select
Selection.Copy
ActiveWorkbook.Sheets("BSR").Select
lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
ActiveWorkbook.Sheets("Data").Select
DT.Select
Selection.ClearContents
End Sub
The error i get is a runtime error 1004
"we cant paste because the copy area and paste area arent the same size.
It only gives this error if there is no data to paste.
Can anyone assist??
Cheers
Dave
I have a macro that copy and pastes data from sheet 3 after i have an external system report populate sheet 3 with data. There are 4 reports that run in a chain and if one doesnt find any data to export to sheet 3 the macro throws up a debug error stopping my report from running
So what i need to add to this macro is a type of error do message to continue and not error if it cant find anything to copy and paste.
The Macro is...
Sub APPENDDATA()
ActiveWorkbook.Sheets("Data").Select
Dim N As Long
N = Cells(1, 1).End(xlDown).Row
Set DT = Range("A1:Y" & N)
DT.Select
Selection.Copy
ActiveWorkbook.Sheets("BSR").Select
lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
ActiveWorkbook.Sheets("Data").Select
DT.Select
Selection.ClearContents
End Sub
The error i get is a runtime error 1004
"we cant paste because the copy area and paste area arent the same size.
It only gives this error if there is no data to paste.
Can anyone assist??
Cheers
Dave