Rename Table using another Cell value

RichSA

New Member
Joined
Jul 14, 2015
Messages
5
Hi,

I am trying to rename a Table using a Macro. I want to rename the Table based on a my own text "CAT_" and cell value in the sheet.

Sub Rename_Table()
ReName = Range("C2").Value
ActiveSheet.ListObjects("Table1").Name = ("CAT_")&ReName
End Sub

Would appreciate some guidance.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try this:
VBA Code:
Sub Name_Me()
'Modified 4/20/2021  3:23:10 AM  EDT
ActiveSheet.ListObjects("Table1").Name = "CAT_" & Range("C2").Value
End Sub
 
Upvote 0
Solution
Try this:
VBA Code:
Sub Name_Me()
'Modified 4/20/2021  3:23:10 AM  EDT
ActiveSheet.ListObjects("Table1").Name = "CAT_" & Range("C2").Value
End Sub
Hi RichSA

I wondered if you wouldn't mind letting me know, the modified code so that the original table name is also looked up from a cell, instead of it being hard set in the code, cell ("C1") say... This is because I have a project with a worksheet containing many tables, all of which I have to change the name of... (Ihave found the code to allow me to get the names exported to a worksheet)

OR

Ideally, and I have been searching all day, I was hoping for code which will allow me to automatically change multiply tables names, throughout a workbook, in one go, based on information that I would enter/list in a worksheet, under header cells say:
A1 (original table name)
B1 (new table name)
as mentioned above, I have found code that will enable me to get the original table names listed, now I just need a way changing them all, as painlessly as possible!

Many thanks in advance!

BNOVA
 
Upvote 0
Hi RichSA

I wondered if you wouldn't mind letting me know, the modified code so that the original table name is also looked up from a cell, instead of it being hard set in the code, cell ("C1") say... This is because I have a project with a worksheet containing many tables, all of which I have to change the name of... (Ihave found the code to allow me to get the names exported to a worksheet)

OR

Ideally, and I have been searching all day, I was hoping for code which will allow me to automatically change multiply tables names, throughout a workbook, in one go, based on information that I would enter/list in a worksheet, under header cells say:
A1 (original table name)
B1 (new table name)
as mentioned above, I have found code that will enable me to get the original table names listed, now I just need a way changing them all, as painlessly as possible!

Many thanks in advance!

BNOVA
Try this:
VBA Code:
Sub Name_Me()
'Modified 4/20/2021  3:23:10 AM  EDT
ActiveSheet.ListObjects("Table1").Name = "CAT_" & Range("C2").Value
End Sub
hey apologies, just realised i should have started with
Hi My Aswer is This!....

also, I meant to say, the tables are throughout a workbook, not worksheet.... TIA
 
Upvote 0
As this is totally different from the original question, you need to start a thread of your own. Thanks
 
Upvote 0

Forum statistics

Threads
1,214,851
Messages
6,121,931
Members
449,056
Latest member
denissimo

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