Error 9 - Subscript Out of Range

tigerdel

Board Regular
Joined
Oct 13, 2015
Messages
101
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
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,412
Office Version
  1. 365
Platform
  1. Windows
Is that workbook the active workbook when you run the code?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,412
Office Version
  1. 365
Platform
  1. Windows
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.
 

tigerdel

Board Regular
Joined
Oct 13, 2015
Messages
101
Office Version
  1. 365
Platform
  1. Windows
Thanks Fluff - it didn't like the Table Name but when I changed it all was well

Cheers
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,412
Office Version
  1. 365
Platform
  1. Windows
Glad to help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,318
Messages
5,623,974
Members
416,002
Latest member
Neshx

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
Top