Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Generating Unique, Sequential Names.

# Generating Unique, Sequential Names

Written by Allen Wyatt (last updated July 23, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021

Steven is testing some software and he needs to feed into the program a bunch of "fake" names. He would like these names to be patterned such as Nameaaa, Nameaab, Nameaac, and so on through Namezzz. This would require creating 17,576 names (26 x 26 x 26). He wonders if there is an easy way to generate all these names in Excel.

This sort of repetitive task just cries out for a macro. (They are great for doing boring, dull, repetitive tasks that you don't want to do manually.) Listing 1 shows a simple macro that can do the required grunt work.

Listing 1. CreateNames macro.
```Sub CreateNames()
Dim i As Integer
Dim x As Integer
Dim y As Integer
Dim z As Integer

i = 1
For x = 97 To 122
For y = 97 To 122
For z = 97 To 122
Cells(i, 1) = "Name" & Chr(x) _
& Chr(y) & Chr(z)
i = i + 1
Next
Next
Next
End Sub
```

The macro uses three variables (x, y, and z) to serve as "counters" that control which letter of the alphabet is appended to the "name" stuffed into a cell. Notice that the For ... Next loops range from 97 to 122, which are the ASCII codes for lowercase a through z.

If you don't want to use a macro for some reason, type the following formula into cell A1 of a blank worksheet:

```="Name" & CHAR((ROW()-1)/676+97)&CHAR(MOD(
(ROW()-1)/26,26)+97)&CHAR(MOD(ROW()-1,26)+97)
```

This is a single formula, and it results in "Nameaaa" being displayed. Copy the formula down through row 17,576 and you'll have your fake names.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12129) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Generating Unique, Sequential Names.

##### Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

##### MORE FROM ALLEN

Indexing Based on a Range of Letters

Word provides many options for creating indexes. One option allows you to specify that the index contain only entries ...

Discover More

Conditional Formatting with Data Imported from Access

If you want to apply a conditional format to data imported into Excel from Access, you may run into some difficulties ...

Discover More

Automatic Selection of Portrait or Landscape

Should you print in portrait or in landscape? The decision can greatly affect the way your printout looks. Wouldn't it be ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

##### More ExcelTips (ribbon)

Macros Run Fine Individually, but Not Collectively

Developing macros can be rewarding, but it can also be challenging. Getting individual macros to run properly is hard ...

Discover More

Turning Off Screen Updating

Want a quick way to speed up your macros? All you need to do is to stop Excel from updating the screen while the macro is ...

Discover More

Inserting Worksheet Values with a Macro

Macros are often used to process information in a worksheet. You may need your macro to change the values stored in ...

Discover More
##### Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. Youâ€™ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine minus 5?

2022-07-23 11:44:13

Andy

For people with Excel 365, this slight modification of Allen's formula will also work. The benefit is it doesn't require filling down.

=LET(index,SEQUENCE(26*26*26)-1,"Name"&CHAR(index/676+97)&CHAR(MOD(index/26,26)+97)&CHAR(MOD(index,26)+97))

##### This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.