ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Runtime 1004 error -- insert method of range class failed. (https://www.excelbanter.com/excel-discussion-misc-queries/144835-runtime-1004-error-insert-method-range-class-failed.html)

tish

Runtime 1004 error -- insert method of range class failed.
 
I'm getting this error when I try to run the macro. This is a worksheet &
macro that I inherited from the previous person. I'm usin Excel 2003. I tried
the macro on another person's computer, same error. I cut and pasted the code
into a blank worksheet and it worked fine!! Anyway, below is the code... Can
anyone offer any guidance on how to fix??

Sub Add_Current_Month()
'
' Add_Current_Month Macro
' Macro recorded 9/6/2001 by Department Of Treasury
'
' Keyboard Shortcut: Ctrl+a
'
Rows("12:12").Select
Selection.Insert Shift:=xlDown
Range("F12").Select
ActiveCell.FormulaR1C1 = "=1"
Range("F13").Select
ActiveCell.FormulaR1C1 = "=1+R[-1]C"
Range("D12").Select
ActiveCell.FormulaR1C1 = "=RC[-1]"
Range("D13").Select
ActiveCell.FormulaR1C1 = "=R[-1]C+RC[-1]"
Range("E12").Select
ActiveCell.FormulaR1C1 = "=RC[-1]/RC[1]"
Range("A12:C12").Select
Selection.Locked = False
Selection.FormulaHidden = False
Range("A13:F13").Select
Selection.Copy
Range("A12:F12").Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("A12").Select
End Sub

tish

Runtime 1004 error -- insert method of range class failed.
 
Lord, there's power in posting..! I figured this one out. Needed to
"unprotect" the worksheet first.. duh!



"tish" wrote:

I'm getting this error when I try to run the macro. This is a worksheet &
macro that I inherited from the previous person. I'm usin Excel 2003. I tried
the macro on another person's computer, same error. I cut and pasted the code
into a blank worksheet and it worked fine!! Anyway, below is the code... Can
anyone offer any guidance on how to fix??

Sub Add_Current_Month()
'
' Add_Current_Month Macro
' Macro recorded 9/6/2001 by Department Of Treasury
'
' Keyboard Shortcut: Ctrl+a
'
Rows("12:12").Select
Selection.Insert Shift:=xlDown
Range("F12").Select
ActiveCell.FormulaR1C1 = "=1"
Range("F13").Select
ActiveCell.FormulaR1C1 = "=1+R[-1]C"
Range("D12").Select
ActiveCell.FormulaR1C1 = "=RC[-1]"
Range("D13").Select
ActiveCell.FormulaR1C1 = "=R[-1]C+RC[-1]"
Range("E12").Select
ActiveCell.FormulaR1C1 = "=RC[-1]/RC[1]"
Range("A12:C12").Select
Selection.Locked = False
Selection.FormulaHidden = False
Range("A13:F13").Select
Selection.Copy
Range("A12:F12").Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("A12").Select
End Sub



All times are GMT +1. The time now is 05:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com