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

Tips.Net > ExcelTips Home > Find and Replace > Searching for Line Breaks

Searching for Line Breaks

Summary: If you have line breaks in some of the cells of your worksheet, you might want to search for them. There is no “special character” you can use for the search, like there is in Word. You can easily find the line breaks by using an ASCII code in the search parameters. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)

Veronica was wondering how to search for a line break (Alt+Enter) in a cell. In Word you can search for ^l to find line breaks, but there does not seem to be a similar way to search for line breaks in Excel.

The answer is to remember that you can enter any ASCII code into the "Find What" box by holding down the Alt key and using the numeric keypad. Since the ASCII code for the line break is 10, you can follow these steps:

  1. Press Ctrl+F to display the Find tab of the Find and Replace dialog box. (Click here to see a related figure.)
  2. In the Find What box, hold down the Alt key as you type 0010 on the numeric keypad. It may not look like anything is in the Find What box, but the character is there.
  3. Click Find Next.

If you want to find cells containing a line break through a macro, you can use the following:

Sub FindLineBreak()
    WhatToFind = Chr(10)
    Cells.Select
    Selection.Find(What:=WhatToFind, After:=ActiveCell, _
      LookIn:=xlValues, LookAt:=xlPart, _
      SearchOrder:=xlByRows, SearchDirection:=xlNext, _
      MatchCase:=False, SearchFormat:=False).Activate
End Sub

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


PivotTables Got You Perplexed? Learn the ins and outs of this powerful data-crunching tool. ExcelTips: PivotTables for the Faint of Heart makes it easy.

Helpful Links

Ask an Excel Question
Make a Comment

Tips.Net Home
Vital News Home

ExcelTips FAQ
ExcelTips Premium

Learn Access Now

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Pet Tips
Word2007 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.)