Excel VBA Current Table Name

JeannetteE

Board Regular
Joined
May 19, 2016
Messages
53
Hi,

I have a Worksheet with multiple Tables, how can I find the Table Name of the Table I'm currently in? Everything seems to point to ListObject(1) but I don't know which ListObject Number it is.

Any help appreciated :)
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi there, I'm not sure if this is what you are looking for, but if you just want the name of the table, you can use:

Code:
ActiveCell.ListObject.Name
 
Upvote 0
Hi there, I'm not sure if this is what you are looking for, but if you just want the name of the table, you can use:

Code:
ActiveCell.ListObject.Name

Thank you, so easy! I've tried the same principle for the Header Name but it doesn't work, ActiveCell.ListColumn.Name nd other variants. Apologies but Tables are new to me.
 
Upvote 0
Thank you, so easy! I've tried the same principle for the Header Name but it doesn't work, ActiveCell.ListColumn.Name nd other variants. Apologies but Tables are new to me.

No problem. If you wish to get the header name for the active cell in the table, you can use something like this:

Code:
Dim ws As Worksheet
Dim tName As String
Dim hName As String
Dim i As Integer

Set ws = ActiveSheet

tName = ActiveCell.ListObject.Name

i = ActiveCell.Column - ActiveCell.ListObject.DataBodyRange.Column + 1
hName = ws.ListObjects(tName).ListColumns(i).Name

MsgBox (hName)
 
Last edited:
Upvote 0
No problem. If you wish to get the header name for the active cell in the table, you can use something like this:

Code:
Dim ws As Worksheet
Dim tName As String
Dim hName As String
Dim i As Integer

Set ws = ActiveSheet

tName = ActiveCell.ListObject.Name

i = ActiveCell.Column - ActiveCell.ListObject.DataBodyRange.Column + 1
hName = ws.ListObjects(tName).ListColumns(i).Name

MsgBox (hName)

Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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