What is Object of new Tables in Excel 2010 VBA?

General Ledger

Active Member
Joined
Dec 31, 2007
Messages
460
Dear All,

For Excel 2010 VBA, what is the Object of the new Tables? It seems to not be Table or DataTable.

I am trying count the number of tables in a workbook, create a Table, and name the Table using the count of tables.

Thanks,

GL
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Vog,

Not quite what I was looking for.

I have the following code that creates a Table in Excel 2010. You get similar code if you record a macro and select from the Insert tab, Tables group, Table. The keyboard shortcut is CTRL+T.

ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1").CurrentRegion, , xlYes).Name = "Table1"

My problem is naming the new Table as Table1. The name may already exist for another Table in my workbook. I want to make the naming of my new table flexible. I want to count the number of Tables in the workbook. I assume there is a Collection for Tables where I can get the count, similar to getting the count of sheets in a workbook (Sheets.Count). Find the number of Tables, add 1, and name the new Table as "Table"&Count + 1

GL
 
Upvote 0
ListObjects - the clue is in the code. ;)
 
Upvote 0
I suspect if you just add the table and let Excel name it, it will be the next one in sequence anyway --> Table1, Table2, Table3

Maybe you can just let it be named this way without trying to get a number yourself.

ξ
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

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