View Single Post
 
Old 11-24-2011, 04:47 AM
leahca leahca is offline Windows XP Office 2010 32bit
Novice
 
Join Date: Oct 2011
Posts: 12
leahca is on a distinguished road
Default Debug for macro run through button only when sheet protected

Hi,

I'm fairly new to macros etc. and need some help with this error. I will post the code below, I'm trying to copy and paste a selection of rows from one worksheet to another using a button. It runs fine until I protect the sheet. When I debug it's pointing to this line:
Code:
Selection.Insert Shift:=xlDown
Error is runtime error 1004
Insert method of range class failed

Here is the code for the entire macro:

Code:
Sheets("2nd page").Select
    Selection.Copy
    Sheets("Job Costing Sheet").Select
    ActiveWindow.SmallScroll Down:=30
    Rows("502:502").Select
    Selection.Insert Shift:=xlDown
    Range("B502:P648").Select
    Application.CutCopyMode = False
    ActiveSheet.PageSetup.PrintArea = "$B$2:$P$648"
    ActiveWindow.SmallScroll Down:=18
    Range("O647").Select
    ActiveCell.FormulaR1C1 = "=SUM(R[-2]C+R[-147]C)"
    Range("O648").Select
    ActiveWindow.SmallScroll Down:=-9
    Range("B624:H624").Select
Any ideas why this runs fine until I protect the sheet? I've tried unprotecting all cells involved etc. but makes no difference.

Thanks!
Reply With Quote