I imported a bunch of data into my Excel from SQL. So I have a bunch of sheets like so:
Each sheet has a table name that I can view in the table view area here:
I was wondering if there is any way to mass re-name the sheets to what the table name is.
Try something like this
Sub RenameSheetToTableName()
Dim ws As Worksheet
Dim tbl As ListObject
For Each ws In ThisWorkbook.Sheets
On Error Resume Next
Set tbl = ws.ListObjects(1)
On Error GoTo 0
If Not tbl Is Nothing Then ws.Name = tbl.Name
Next ws
End Sub