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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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