Table name issue

mtterry

New Member
Joined
Aug 9, 2016
Messages
45
The code pasted below is resulting in a table name that starts with an underscore, and I can't understand why - any help would be appreciated.

ActiveSheet.ListObjects.Add(xlSrcRange, Range([A1].End(xlDown), [A1].End(xlToRight)), , xlYes).Name = _
Month(pmtDate) & "_" & Year(pmtDate) & "_" & uploadType
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
A table name can't begin with a number, so Excel is adding an underscore for you.
 
Upvote 0
This part of your code ").Name = _" is defining the name being given so if you remove that underscore it will go away.

The code pasted below is resulting in a table name that starts with an underscore, and I can't understand why - any help would be appreciated.

ActiveSheet.ListObjects.Add(xlSrcRange, Range([A1].End(xlDown), [A1].End(xlToRight)), , xlYes).Name = _
Month(pmtDate) & "_" & Year(pmtDate) & "_" & uploadType
 
Upvote 0
This part of your code ").Name = _" is defining the name being given so if you remove that underscore it will go away.

That's a VBA line continuation character, not part of the name string being assigned.
 
Upvote 0
Yes, because of the number at the start.
 
Upvote 0
Don't start the name with a number. Table names follow the same rules as defined names - they have to start with a letter or underscore.
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,770
Members
449,049
Latest member
greyangel23

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