Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-24-2011, 04:47 AM
leahca leahca is offline Debug for macro run through button only when sheet protected Windows XP Debug for macro run through button only when sheet protected Office 2010 32bit
Novice
Debug for macro run through button only when sheet protected
 
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
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I assign a macro to a button when the macro is in my personal workbook? foolios Excel Programming 2 07-27-2011 02:41 PM
Word doc bug when closing from userform command button click macro Joe Patrick Word 1 07-05-2011 08:53 PM
Macro Button B2W Excel 2 06-18-2010 09:36 AM
copy cell from sheet 2 to sheet 3 macro slipperyjim Excel Programming 1 02-18-2010 01:31 AM
Microsoft Office 2003 winword.exe Debug Error! abnormal prog elo1bev Word 0 12-22-2005 10:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2023 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft