Need some code to make all table in worksheets into dynamic table

Faisal Yunianto

New Member
Joined
Apr 21, 2023
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hello Guys!

I have 99 worksheet and I want to make all table in sheet to be a dynamic table. When I use recorded macro and I applied to another sheet always had a problem. The notification said “Run-time error ‘1004’: Application-defined or object-defined error”. Can you help me? I want to make all table sheet into dynamic table and the name of dynamic table same as the sheet name and I need some VBA code to handle this. Additional note, I don’t have basic VBA. Thanks!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Welcome to the forum Faisal,

Couple of questions:
How many tables will each sheet have?
If there are more than one, what will seperate them?
Do you have sheets that you don't want to make tables from?

Below is a small piece of code that loops through the sheets in a workbook and makes a table from the used range of each sheet, it then names the table after the sheet name:
VBA Code:
Sub test()
    Dim ws As Worksheet
    
    For Each ws In Sheets
        ws.ListObjects.Add(xlSrcRange, ws.UsedRange, , xlYes).Name = "tbl" & ws.Name
        ws.ListObjects("tbl" & ws.Name).TableStyle = "TableStyleMedium10" ' optional
    Next ws
End Sub
 
Upvote 0
Solution
Oh My God, It works! Thank you so much!
Each sheets only have one table
 

Attachments

  • 2023-11-14_160453-min.jpg
    2023-11-14_160453-min.jpg
    218.3 KB · Views: 7
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,146
Members
449,098
Latest member
Doanvanhieu

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