bottom
Great ExcelTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > ExcelTips Home > Worksheet Functions > Text Functions > Using the REPT Function

Using the REPT Function

Summary: The REPT worksheet function is helpful for repeating a character or series of characters through the whole width of a cell. This tip explains how to use this rather esoteric function. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)

Excel includes a worksheet function that allows you to repeat a text string any number of times: REPT. For instance, suppose cell B1 contains the value 5, and cell C1 contains the following:

=REPT("*", B1)

What Excel shows is five asterisks (*****) in cell C1. REPT takes whatever is in the quote marks and repeats it the number of times specified. If the string is more than one character, then it is also repeated that number of times. For instance, consider the following:

=REPT("/\", B1)

Assuming B1 still contains the value 5, this results in a ten-character string: /\/\/\/\/\. If you don't typically wax graphic or want to use Excel's charting features, you can use the REPT function to create simple histograms of your data.

The only caveat is that the string created by REPT cannot be any longer than 1,024 characters if you are using Excel 97. In later versions of Excel the created string can be up to 32,767 characters. If you exceed the limits of your Excel version you won't get an error, you just get a truncated string.

Tip #2160 applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003


Save Time and Money! Many people need to keep track of employee time, but don't know where to start when it comes to creating a spreadsheet. Here's a way to save time, effort, and money with ready-to-use timesheet templates.
 
Check out Timesheet Templates today!

Helpful Links

Ask an Excel Question
Make a Comment

Tips.Net Home

ExcelTips FAQ
ExcelTips Premium

Learn Access Now

Bugs and Pests Tips
ExcelTips
Family Tips
Health Tips
Home Tips
Organizing Tips
WordTips

Advertise on the
ExcelTips Site

 

Great Info!

Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)