2 different spreadsheets:
1 created and running on excel 2003 - works
1 created and running on excel 2007 - works
The VBA code to insert a row keeping the formulas from row above IS THE SAME on each spreadsheet -
However if I copy the 2003 spreadsheet to my system running excel 2007 - I get an error
Run-time error '1004'
Insert method of Range class failed
If I copy the 2007 spreadsheet to my system running excel 2003 - I get an active X error.
I need to create a spreadsheet with an insert Row macro (attached to a button) - that will work whether run on Excel 2003 or 2007.
Here's the code....
Private Sub CommandButton2_Click()
ActiveSheet.Unprotect Password:="somepassword"
Application.ScreenUpdating = False
Dim cell As Range
Selection.EntireRow.Insert -->ERROR OCCURS HERE
For Each cell In Intersect(ActiveSheet.UsedRange, Selection.Offset(-1, 0).EntireRow)
If cell.HasFormula Then
cell.Copy cell.Offset(1, 0)
End If
Next
Application.ScreenUpdating = True
ActiveSheet.Protect Password:="somepassword"
End Sub
Any help /guidance will be greatly appreciated. I can't believe how incompatible these two versions are!!!!!
thanks
jill
1 created and running on excel 2003 - works
1 created and running on excel 2007 - works
The VBA code to insert a row keeping the formulas from row above IS THE SAME on each spreadsheet -
However if I copy the 2003 spreadsheet to my system running excel 2007 - I get an error
Run-time error '1004'
Insert method of Range class failed
If I copy the 2007 spreadsheet to my system running excel 2003 - I get an active X error.
I need to create a spreadsheet with an insert Row macro (attached to a button) - that will work whether run on Excel 2003 or 2007.
Here's the code....
Private Sub CommandButton2_Click()
ActiveSheet.Unprotect Password:="somepassword"
Application.ScreenUpdating = False
Dim cell As Range
Selection.EntireRow.Insert -->ERROR OCCURS HERE
For Each cell In Intersect(ActiveSheet.UsedRange, Selection.Offset(-1, 0).EntireRow)
If cell.HasFormula Then
cell.Copy cell.Offset(1, 0)
End If
Next
Application.ScreenUpdating = True
ActiveSheet.Protect Password:="somepassword"
End Sub
Any help /guidance will be greatly appreciated. I can't believe how incompatible these two versions are!!!!!
thanks
jill