Error 9 - Subscript Out of Range

tigerdel

Board Regular
Joined
Oct 13, 2015
Messages
145
Office Version
  1. 365
Platform
  1. Windows
I have a UserForm that adds New Suppliers to a Table but I get an error [see title] at the line Set tbl = ws.ListObjects("Supplier")

The SheetName is correct and I have a Table called Supplier on that sheet

Code:
Private Sub cmdAddSupplier_Click()
Dim ws As Worksheet
Set ws = Sheets("Lists")
Dim tbl As ListObject
Set tbl = ws.ListObjects("Supplier")
Dim newRow As ListRow
Set newRow = tbl.ListRows.Add
With newRow
    .Range(1) = txtPayeeName
    .Range(2) = cmbVATType
    .Range(3) = cmbHeaders
End With
Unload Me
End Sub

Any suggestions gratefully received

Many thanks
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Is that workbook the active workbook when you run the code?
 
Upvote 0
In that case double check the name of the table, for any possible typos.
I'm assuming that it is a structured table, rather than a named range.
 
Upvote 0
Thanks Fluff - it didn't like the Table Name but when I changed it all was well

Cheers
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,397
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top