Excel 2003 - 2007 compatibility headaches

jill

New member
Joined
Sep 24, 2012
Messages
1
Reaction score
0
Points
0
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
 

jpl73

New member
Joined
Sep 10, 2012
Messages
21
Reaction score
0
Points
0
Are you copying the workbook from one system to another? I never ran into issues with macros but when I transfer the workbooks from one place to another, I use Save As, this way the macros don't get lost or confused. I have noticed that when I would copy a book ,the macros name shows for the previous workbook. So try the Save As.

Jpl73
 
Top