VBA formal using a table name refrence

gberg

Board Regular
Joined
Jul 16, 2014
Messages
180
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet that has multiple tabs. I need a VBA formula that will use the table name on each tab that it is run on.

I have this to get the table name of the table on each tab
Range("A3").Select
Dim tName As String
tName = ActiveCell.ListObject.Name



Here is an example of the formula I want (it has "Table19" which is what I want to replace with "tName" from above)

Range("E858").FormulaR1C1 = "=SUMIF(Table19[PROD],[@[PRODUCT LINE]],Table19[WEEKLY PAYROLL])"

I tried this but it just gives me an error

"=SUMIF(tName & "[PROD]",[@[PRODUCT LINE]],tName & "[WEEKLY PAYROLL]")"

Any help would be appreciated

Thanks,

Greg
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I think I figured it out

'Get Table Name
Range("A3").Select
Dim tName As String
tName = ActiveCell.ListObject.Name

Range("E858").FormulaR1C1 = "=SUMIF(" & tName & "[PROD],[@[PRODUCT LINE]]," & tName & "[WEEKLY PAYROLL])"
 
Upvote 0
Solution

Forum statistics

Threads
1,215,363
Messages
6,124,505
Members
449,166
Latest member
hokjock

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