How to fix Run-time error 448

I used some old code created in Excel 2007 and repurposed it for another file in Excel 2003.  See code below.  

The user got a run-time error 448.  I imagine there is some wording in the code that isn't suited to the prior version of Excel?  Or is it that UserInterfaceOnly should equal False?  Unfortunately, I can't recreate the problem on my PC.  The code words great in Excel 2010's compatibility mode.

Any light you can shed, would be very much appreciated!
Sub InsertTableRow()

 Range("B9").Select
    ActiveSheet.Unprotect Password:="password"
    Selection.ListObject.ListRows.Add AlwaysInsert:=False
    ActiveSheet.Protect Password:="password", UserInterfaceOnly:=True, AllowSorting:=True, AllowFormattingCells:=True, _
                    AllowInsertingRows:=True, AllowDeletingRows:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True
    ActiveCell.Select
    Call IndextoLastRowinTable

End Sub

Sub IndextoLastRowinTable()
'
'
    Range("B300").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(-1, 0).Range("A1").Select
End Sub

Open in new window

LVL 1
xllvrAsked:
Who is Participating?
 
GrahamSkanConnect With a Mentor RetiredCommented:
Just try:

Selection.ListObject.ListRows.Add

without the  AlwaysInsert=False bit.
0
 
vguzmanIT ManagerCommented:
are both subs in the same worksheet/module ?
if not make sure IndextoLastRowinTable its a public sub
0
 
vguzmanIT ManagerCommented:
is the code stopping at ActiveSheet.Protect... line ?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
xllvrAuthor Commented:
Both subs are in the same module.  In terms of your other question, I'm not certain where the code is stopping but can ask tomorrow.  

If it is stopping at that line, do you have a suggestion as to how I should handle it?  

Thanks so much for replying!
0
 
GrahamSkanRetiredCommented:
I think that that AlwaysInsert argument was not there in Excel 2003

Selection.ListObject.ListRows.Add AlwaysInsert:=False
0
 
xllvrAuthor Commented:
Graham,

Just heard from the user and the line the code hangs up on is exactly what you just mentioned.

Selection.ListObject.ListRows.Add AlwaysInsert:=False

Any suggestions as to how I can allow the user to insert a row within the table and avoid the code hanging up on him?

Thanks!
0
 
xllvrAuthor Commented:
Hope your holiday was good!  Was hoping to re-engage on this question.  Is there a line of code I can use to replace

Selection.ListObject.ListRows.Add AlwaysInsert=False

or the user who is working in Excel 2003?  Again, the idea is for the user to be able to insert a row within a Table/List in Excel 2003 while the sheet is protected.  (All code is attached above.)
0
 
xllvrAuthor Commented:
Thanks so much for following through!  Much appreciated.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.