change table name based on a table column and another cell

chips

Board Regular
Joined
Oct 21, 2008
Messages
52
Hello,
I copied a worksheet and this has named all tables incorrectly is there a way to automatically change the name of all tables in a worksheet?

I have 28 tables for each day of the week

each table has 4 columns:

Index, code, shift, (and names of the days eg table 1 MON1 table 2 TUE2 etc)

Ive typed the department name in a1 called ANAES

Is it possible to change all of the tables in the active worksheet to correspond with the dept name and the day of the week found in column 4?
so the end result is
eg wk1
table 1 = tabANAESMON1
table2 =tabANAESTUE1
etc for all of the rest of the days of the week

then for the next week change the names to
eg wk2
Table renamed to =tabANAESMON2
tabTUES2
etc

and continue for the remaining tables
wk3
tabANAESMON3

wk 4
tabANAESMON4

thank you for any help you can provide
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
How about
VBA Code:
Sub Chips()
   Dim Tbl As ListObject
   
   For Each Tbl In ActiveSheet.ListObjects
      Tbl.Name = "Tab" & Range("A1").Value & Tbl.ListColumns(4).Name
   Next Tbl
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub Chips()
   Dim Tbl As ListObject
  
   For Each Tbl In ActiveSheet.ListObjects
      Tbl.Name = "Tab" & Range("A1").Value & Tbl.ListColumns(4).Name
   Next Tbl
End Sub
OMG thank you so much after hours of trying to figure this out myself you came along and rescued my night! thank you! i can t believe the wonderful help that is offered here on this board . thank you
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,237
Messages
6,123,800
Members
449,127
Latest member
Cyko

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