Hello. I am having troubles with a sub routine that selects a range and converts that range to a list object. I am able to successfully create the ListObject, but when it sets the name it appends an "_" at the end of the table name if the variable ends in a number.
For example:
Dim tableName As String
tableName = "abc123"
Set Rng = Worksheets(dataInsertWorksheet).range(Worksheets(dataInsertWorksheet).range("A1"), Worksheets(dataInsertWorksheet).range("A1").SpecialCells(xlLastCell))
Worksheets(dataInsertWorksheet).ListObjects.Add(xlSrcRange, Rng, , xlYes).Name = tableName
The above code will create the ListObject and assign the name "abc123_" to it. If I set the tableName variable to just "abc" it will not append an underscore at the end. I'm not sure why this happens because table names CAN end in a number, it is only when I dynamically create the ListObject through VBA that it will not accept numbers at the end of the name.
Thank you for any suggestions
For example:
Dim tableName As String
tableName = "abc123"
Set Rng = Worksheets(dataInsertWorksheet).range(Worksheets(dataInsertWorksheet).range("A1"), Worksheets(dataInsertWorksheet).range("A1").SpecialCells(xlLastCell))
Worksheets(dataInsertWorksheet).ListObjects.Add(xlSrcRange, Rng, , xlYes).Name = tableName
The above code will create the ListObject and assign the name "abc123_" to it. If I set the tableName variable to just "abc" it will not append an underscore at the end. I'm not sure why this happens because table names CAN end in a number, it is only when I dynamically create the ListObject through VBA that it will not accept numbers at the end of the name.
Thank you for any suggestions