Subscript out of range

biafrapl

New Member
Joined
Mar 31, 2020
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi,

When I look at the Name Manager I can find a table called QUOTA_1, but when I reference it in VBA code I get the subscript out of range error. Have you encountered anything like that in the past?

I'm using Excel for Office 365
 

Attachments

  • 1.png
    1.png
    2 KB · Views: 4
  • 2.png
    2.png
    4.3 KB · Views: 4

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi & welcome to MrExcel.
Is sheet "Quota" the active sheet when you run that code?
 
Upvote 0
How have you declared ws & tbl?
 
Upvote 0
Yes I did.

I am using Microsoft Master Data Services to pull data from SQL to excel spreadsheet. While connecting to MDS the QUOTA_1 table is being created automatically. It seems that I have only issue with referencing this table.
 

Attachments

  • 3.png
    3.png
    3.6 KB · Views: 5
Upvote 0
I have never used MDS & so cannot help any further.
 
Upvote 0
Ok, thanks.

What is really weird is that when I have something like that:

Range("QUOTA_1[[#All],[Industry Growth]]").Select

Everything works perfectly. But when I try to execute the following code it fails and gives error:

Dim ws As Worksheet
Dim tbl As ListObject

Set ws = ActiveSheet
Set tbl = ws.ListObjects("QUOTA_1")
 
Upvote 0
Longwinded, but see if this works
VBA Code:
Set tbl = ws.ListObjects(Range("Table4").ListObject.Name)
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

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