Convert ExternalData_1 to table in VB script

lucsmitty

New Member
Joined
Jul 27, 2011
Messages
1
Hi all,

I've done a ton of googling and can't find the answer, so I'm asking the question. I have a worksheet that has several pages that need formatting work that should bee scripted. I want to change a ExternalData_1 to a table so I can give it a different visual format. The problem is when I record the macro to do it, it automatically fills out the range and doesn't give a clue on how to find the range of the ExternalData_1 in order to know how large to make the table. Below is the code from recording a macro:

ActiveSheet.QueryTables("ExternalData_1").Delete
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$2:$C$5"), , xlYes).Name = _
"Table10"
Range("Table10[#All]").Select
ActiveSheet.ListObjects("Table10").TableStyle = "TableStyleMedium7"

How do I get the right range to do this in a script since the tables will be different for each sheet in the workbook? Thanks.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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