Excel.Tips.Net Welcome toExcel.Tips.Net

Helpful Links

Tips.Net Home
ExcelTips Home
Ask an Excel Question
Make a Comment

Tips.Net Store

ExcelTips FAQ
ExcelTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

Newest Tips

Converting to Octal

Filtering Columns for Unique Values

Printing Multiple Worksheets on a Single Page

Changing the Default Font

Creating a Drawing Object

Determining a Value of a Cell

Understanding Macros

 

AutoFilling with the Alphabet

Summary: Creating your own custom word search puzzles in Excel can present you with an interesting problem: how to fill a range of empty cells with letters of the alphabet. It turns out that there are several different ways you can accomplish the task, as this tip details. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)

Marlene is a teacher, and she has students who love word searches. She finds it quite time consuming to make them, but the students seem to remember the course material much better when she uses them. Marlene wondered if there was some way to AutoFill a range of cells with letters of the alphabet, A through Z. That way she can use the feature to fill in the squares of the word search with letters, before she replaces some of those letters with the actual words to be searched.

The AutoFill tool in Excel has a few standard sequences it will fill automatically, such as dates and numeric sequences. The very powerful part of AutoFill, however, is that you can create custom lists that the tool uses just as easily as the built-in sequences. In order to create a custom list manually, you can follow these steps:

  1. Choose Options from the Tools menu. Excel displays the Options dialog box.
  2. Make sure the Custom Lists tab is selected. (Click here to see a related figure.)
  3. In the Custom Lists column, make sure NEW LIST is selected.
  4. In the List Entries box, enter each letter of the alphabet, one letter per line. (Press Enter after each letter you type.)
  5. Click Add.

You've now created your custom list, and you can close any open dialog boxes. To use the custom list, just type one or two letters you want to start the sequence with, select those cells, and use the AutoFill handle to drag over as many cells as you want to fill.

There's another way to create the custom list that may be a bit easier, just in case you don't want to type twenty-six letters in the dialog box. Instead, if you already have the letters of the alphabet in twenty-six cells, simply select those cells and follow these steps:

  1. Choose Options from the Tools menu. Excel displays the Options dialog box.
  2. Make sure the Custom Lists tab is selected. The range of cells you selected should be shown in the Import List from Cells box.
  3. Click Import.

Now you can close the dialog box and use the custom list as you desire.

Of course, there is one drawback with using a custom AutoFill list, especially when it comes to creating word searches: the letters added to blank squares are always in a predictable sequence, which could make finding the actual words a bit easier than you want. To make the puzzles a bit more challenging, it would be better to fill the non-word squares with random letters.

One easy way to get random letters is to use the following formula:

=CHAR(RANDBETWEEN(65,90))

This formula works because the RANDBETWEEN function returns a random numeric value between the two boundary values provided. In this case, it will return a value between 65 and 90, which are the ASCII values of the letters A and Z, respectively. The CHAR function is then used to convert this random numeric value into an actual letter.

The RANDBETWEEN function is part of the Analysis ToolPak, an add-in which many people have installed in Excel. (Choose Tools | Add-ins to see if you have it installed.) If you prefer to not have the add-in enabled, then you can rely upon a more basic formula, such as the following:

=CHAR((65+(90-65)*RAND()))

The CHAR function should look familiar; the only difference is the use of the RAND function to generate the random value instead of RANDBETWEEN.

If you create a lot of word search puzzles, then you may want to use a macro to fill a range of cells with random letters of the alphabet. There are any number of ways that such a macro could be put together; the following is one that is particularly flexible. It will work with either a pre-selected range (a range selected when you run the macro) or you can select a range after you run the macro.

Sub AlphaFill()
    Dim Cell, CellChars
    Dim Default, Prompt, Title
    Dim rangeSelected As Range
    Dim UpperCase As Boolean

    Title = "AlphaFill Cell Selection"
    Default = Selection.Address
    Prompt = vbCrLf _
      & "Use mouse in conjunction with " _
      & "SHIFT and CTRL keys to" & vbCrLf _
      & "click and drag or type in name(s) " _
      & "of cell(s) to AlphaFill" & vbCrLf & vbCrLf _
      & "Currently selected cell(s): " _
      & Selection.Address

    On Error Resume Next
    Set rangeSelected = Application.InputBox(Prompt, Title, _
      Default, Type:=8)
    If rangeSelected Is Nothing Then Exit Sub

    UpperCase = True
    Randomize
    For Each Cell In rangeSelected
        CellChars = Chr(64 + Int((Rnd * 26) + 1))
        If Not UpperCase Then CellChars = LCase(CellChars)
        Cell.Value = CellChars
    Next
End Sub

The macro code, as written, inserts the uppercase letters into whatever range you specify. If you want to use lowercase letters instead, then all you need to do is set the UpperCase variable to False rather than True.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3109) applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003

Step Up and Take Control! Subscribers to ExcelTips know just how valuable a resource it is. ExcelTips Premium provides twice the number of exceptional, easy-to-understand tips every week in an ad-free newsletter, as well as substantial discounts on ExcelTips archives and e-books.
 
Check out ExcelTips Premium today!