Skip to main content

How to prevent auto numbering at duplicate column header in Excel table?

Author: Sun Last Modified: 2022-10-21

In Excel, when you type the duplicate column header in the table, it will be auto-added a number just as name, name1, name2, and the number cannot be removed as the below screenshot shows. To prevent the auto numbering at duplicate column header in table, you can add trailing space to the duplicate header. Here is a VBA code that can help you repeat the header and auto-add trailing spaces to let them different but looks the same.
auto complete from another list

Auto add trailing spaces to header

Note: the methods provided in this tutorial are tested in Excel 2021, there may be some different in different Excel verisions.

Auto add trailing spaces to header

1. Type the headers you want to repeat in a column, then press Alt + F11 keys to enable Microsoft Visual Basic for Applications window.

2. Click Insert > Module to create a new module in the Microsoft Visual Basic for Applications window, then copy and paste the below code to it.

VBA: Repeat and add trailing spaces

Sub repeat()
    Dim xRg As Range
    Dim saveRg As Range
    Dim xIndex As Integer
    Dim xCount As Integer
    Dim k As Integer
    Dim xStr As String
    Set xRg = Application.InputBox("Select the cells that you want to repeat", "kte", , , , , , 8)
    xIndex = Application.InputBox("Enter the repeat times", "kte")
    Set saveRg = Application.InputBox("Select a cell to output", "kte", , , , , , 8)
    xStr = ""
    xCount = xRg.Cells.Count * xIndex
    Set saveRg = saveRg.Range("a1").Resize(1, xCount)
    k = 0
    For i = 1 To xIndex
        For j = 1 To xRg.Cells.Count
            k = k + 1
            saveRg.Cells(k).Value = xRg.Cells(j).Value + xStr
        xStr = xStr + " "
End Sub

 auto complete from another list

3. Click Run auto complete from another list button in the ribbon or press F5 key to activate the code, in the first popping dialog, select the headers you want to repeat. Click OK.
auto complete from another list

4. In the second popping dialog, type the repeating times you want. Click OK.
auto complete from another list

5. Select a cell that you want to output the repeated headers. Click OK.
auto complete from another list

Now the headers have been repeated and added with trailing spaces.
auto complete from another list

6. Select the headers and copy them by pressing Ctrl + C, and paste them back to the table you need by pressing Ctrl + V.

Now you can see the table has duplicate column headers without numbering.
auto complete from another list

Other Operations (Articles)

How To Find Maximum Or Minimum Absolute Value And Keep Sign In Excel
Sometimes, you may want to find the maximum or minimum values of their absolute values but keep their sign when returning the result as the below screenshot shows.

How To Keep Leading Apostrophe When Typing In Excel?
As we know, when you want to change a number to a text, you can enter an apostrophe symbol at the front like this: ‘123, and the number will be converted to a text and hide the apostrophe.

How To Force To Open As Read Only In Excel?
Sometimes, you want other users who open your shared workbooks to be cautious when they are going to edit the shared workbooks, you can make a read-only prompt to warn them...

How To Stop Excel From Auto Formatting Dates In CSV?
Here is a csv file which contains the date as text format 12-may-20 but when you open through excel will be auto stored as date format...

  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns and Keeping Data; Split Cells Content; Combine Duplicate Rows and Sum/Average... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Favorite and Quickly Insert Formulas, Ranges, Charts and Pictures; Encrypt Cells with password; Create Mailing List and send emails...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • Pivot Table Grouping by week number, day of week and more... Show Unlocked, Locked Cells by different colors; Highlight Cells That Have Formula/Name...
kte tab 201905
  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations