thornomad
thornomad

Reputation: 6777

How do I pass a ListObject as a variable?

Am not that skilled at Excel/VBA and need some help. The code below (in its simplest form) throws a runtime error (13) stating I have a type mismatch. I don't understand how it's mismatched since I've declared them as the same type. Any ideas?

Sub Setup_ListObject()
    Dim the_list As ListObject
    Do_stuff_with_ListObject (the_list)  ' ** runtime error highlights "type mismatch"
End Sub
Private Sub Do_stuff_with_ListObject(ByRef a_list As ListObject)
    ' here we do stuff
End Sub

Upvotes: 0

Views: 3626

Answers (1)

Siddharth Rout
Siddharth Rout

Reputation: 149305

Remove the brackets. Use this

Do_stuff_with_ListObject the_list

or if you want to use brackets then do this

Call Do_stuff_with_ListObject(the_list)

Upvotes: 4

Related Questions