Share via

2007 Excel Macro - Error on "Selection.Insert Shift:=xlDown" line

Anonymous
2011-11-17T17:48:19+00:00

2007 Excel Macro - Trying to write a macro to copy a selection (say A3: L19), and paste that below (with say a row space).  I'm going to link the macro to a button on the worksheet, so, this process needs to find the next free row each time the button is clicked.  I have tried utilising a macro which works on another workbook, but is failing on this new workbook around the following issue - "Selection.Insert Shift:=xlDown" line - reporting a "Run-time error '1004' - This selection is not valid". 

Current code as follows:

ActiveSheet.Unprotect

Range("A3:L19").Select

Selection.Copy

Application.Goto Reference:="R4C1"

Selection.Insert Shift:=xlDown

ActiveSheet.Protect

Any thoughts would be appreciated. 

Thanks

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-11-17T19:03:21+00:00

... Trying to write a macro to copy a selection (say A3: L19), and paste that below (with say a row space) ...

Your code snippet seems to differ from your description of the events to take place. According to your description, try this,

ActiveSheet.Unprotect

    Range("A3:L19").Copy Destination:=Cells(Rows.Count, "A").End(xlUp).Offset(2, 0)

    ActiveSheet.Protect

The Offset(2,0) leaves a blank row before pasting the copied cells. If no blank row is desired, use Offset(1,0) for the first blank row.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful