# Generating Unique, Sequential Names

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Generating Unique, Sequential Names.

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.) Here is a simple macro that can do the required grunt work:

```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 counter variables (x, y, and z) to serve as "counter variables" 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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12128) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Generating Unique, Sequential Names.

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

 *Name: Email: Notify me about new comments ONLY FOR THIS TIP Notify me about new comments ANYWHERE ON THIS SITE Hide my email address *Text: *What is 5+3 (To prevent automated submissions and spam.)

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)

# Our Company

Sharon Parq Associates, Inc.

# Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Excel Products

Word Products

# Our Authors

Author Index

Write for Tips.Net