I am creating a macro but I am stuck at this cut paste statement and not able to proceed since yesterday.
Here is the problem: I am selecting all the rows in column "D2 to F2" and pasting it at "A1". Here is the code for it :
Range("D2:F2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Here's what I have tried :
Code Change: Using
PasteSpecial
instead of simplePaste
.Range("D2:F2").Select Range(Selection, Selection.End(xlDown)).Select Selection.Cut Range("A1").Select Selection.End(xlDown).Select ActiveCell.Offset(1, 0).Select 'ActiveSheet.Paste ' insted of this using paste special. ActiveSheet.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Code Change: Resized the selection to 3 columns.
Range("D2:F2").Select Range(Selection, Selection.End(xlDown)).Select Selection.Cut Range("A1").Select Selection.End(xlDown).Select ActiveCell.Offset(1, 0).Resize(1, 3).Select 'ActiveSheet.Paste
- Tried
On Error Resume Next
statement. It is ignoring the error message but not pasting the data as well.
I am looking for a way to ignore this error message and proceed with paste. We normally get this error when we manually copy-paste
or cut-paste
in excel sheet, there we have option to ignore and paste data. Similarly is there any method to ignore it within a macro?