extracting or replacing table names

Joined
Jan 3, 2012
Messages
20
I have a big workbook with approx 100 sheets. In each sheet I have two tables, and as I manually entered all the data, I just copied the sheet layout, so now I have funny table names like RHO925_stamdata1012223064666870727682.

I would like to replace these names.

I have found a way to change the table name, but it requires that I know the current name.

How can I extract the current Table name or replace it without know the current Table name ?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try this, it will auto rename the table to "Tablexxx".

Code:
[COLOR=#0000cd]Sub AutoTableRename()
[/COLOR][COLOR=#d3d3d3]'by lhartono[/COLOR][COLOR=#0000cd]
Dim wsh     As Worksheet
Dim tbl     As ListObject
Dim idx     As Long

For Each wsh In ActiveWorkbook.Sheets
    For Each tbl In wsh.ListObjects
        idx = idx + 1
[/COLOR][COLOR=#d3d3d3]        'Debug.Print wsh.Name & vbTab & tbl.Name & vbTab & ("Table" & Format(idx, "000"))[/COLOR][COLOR=#0000cd]
        tbl.Name = ("Table" & Format(idx, "000"))
    Next
Next

End Sub[/COLOR]
 
Upvote 0
Thank a lot - you solved my problems. Have a Nice day.






Try this, it will auto rename the table to "Tablexxx".

Code:
[COLOR=#0000cd]Sub AutoTableRename()
[/COLOR][COLOR=#d3d3d3]'by lhartono[/COLOR][COLOR=#0000cd]
Dim wsh     As Worksheet
Dim tbl     As ListObject
Dim idx     As Long

For Each wsh In ActiveWorkbook.Sheets
    For Each tbl In wsh.ListObjects
        idx = idx + 1
[/COLOR][COLOR=#d3d3d3]        'Debug.Print wsh.Name & vbTab & tbl.Name & vbTab & ("Table" & Format(idx, "000"))[/COLOR][COLOR=#0000cd]
        tbl.Name = ("Table" & Format(idx, "000"))
    Next
Next

End Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,833
Members
452,947
Latest member
Gerry_F

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