+ Reply to Thread
Results 1 to 14 of 14

Formula to search all cells in a workbook for characters longer than 6

  1. #1
    Registered User
    Join Date
    04-08-2013
    Location
    Bay Area, Califormia
    MS-Off Ver
    Excel 2013
    Posts
    5

    Formula to search all cells in a workbook for characters longer than 6

    Hi,

    I'm looking for a formula that will check all cells in a workbook for characters longer than 6 and then if longer than 6 I need it to replace the data in that cell with "n/a". I know it has to be a combination of using a named range that encompasses an entire workbook, and then a formula like: If Cell in (named range) is > Len(6) then "N/A". Something like that, but not sure. Just trying to avoid ###### in a cell which does not look good, and I don't want to increase column width. Also cannot use VBA for this.

    Thanks in advance.

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula to search all cells in a workbook for characters longer than 6

    Not possible using formulas.

    check all cells in a workbook
    Can you narrow that down to a more realistic range?

    Are there any formulas in any cells?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    04-08-2013
    Location
    Bay Area, Califormia
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Formula to search all cells in a workbook for characters longer than 6

    Thanks for the quick reply. I guess I could setup a named range that just covers each work sheet and then use an if statement to check each cell, but was hoping I could avoiding having to do that, because I have 15 worksheets to cover. Yes most of the cells with have formulas, I was thinking I would just wrap this formula around the existing ones.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula to search all cells in a workbook for characters longer than 6

    Do you want this to apply to formula results also? Or, just hard entered data?

  5. #5
    Registered User
    Join Date
    04-08-2013
    Location
    Bay Area, Califormia
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Formula to search all cells in a workbook for characters longer than 6

    Any resulting data or formula results that shows ###### for the cell. Which would only occur if the data or characters in that cell are larger than the cell can display.

  6. #6
    Registered User
    Join Date
    04-08-2013
    Location
    Bay Area, Califormia
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: Formula to search all cells in a workbook for characters longer than 6

    Is there a function or conditional format that can change a cell showing ###### and substitute "n/a" in that cell? Just don't want to show ######. I know I can just widen the column width but that also squeezes other cells and increases the width of the sheet.

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Formula to search all cells in a workbook for characters longer than 6

    If the data is just too wide for the column, you could use something like...
    =if(len(cell-ref)>??,"",cell-ref)
    where ?? would be the minimum width you want to show
    This would be done IN the formula in that cell

    If the #### is coming from an error...
    =IFERROR(your-formula,"")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  8. #8
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Formula to search all cells in a workbook for characters longer than 6

    This just seems 'wrong', but is probably the least expensive method:

    1. Select the entire worksheet by clicking the 'Select All' button, or pressing CTRL-A
    2. Click Conditional Formatting and enter the formula =LEN(A1)>6, where 6 is your max display length
    3. Set the Format to Font Color = White, or whatever your sheet's background colour is.

    In the example below, cells B2:H13 and B15:H26 have identical contents, but I have applied the above formatting only to B15:H26.

    hide_hash_cells.jpg

  9. #9
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Formula to search all cells in a workbook for characters longer than 6

    Whatabout using the in-built find and replace?

    I.e. press CTRL + H, Find what: type ??????? (7 question marks), Replace with: n/a, click Options>>, Look in: Values, Replace All.

    Edit: Or if you're looking for ###s, just do the above, but instead of searching for questions marks you search ######.

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula to search all cells in a workbook for characters longer than 6

    Quote Originally Posted by quekbc View Post
    Whatabout using the in-built find and replace?

    I.e. press CTRL + H, Find what: type ??????? (7 question marks), Replace with: n/a, click Options>>, Look in: Values, Replace All.
    That's what I was thinking about.

    I would use ???????* as the criteria.

    Also, be very careful if using this method as it will evaluate the length of a formula (not necessarily the formula result). For example, this formula:

    =IF(TODAY()>1,"Y","N")

    Returns a single character but the formula itself is 22 characters long so the Find/Replace would replace the formula with the N/A.

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula to search all cells in a workbook for characters longer than 6

    Before you try ANY of the suggestions I would advise you to make a backup copy of the file just in case!

  12. #12
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Formula to search all cells in a workbook for characters longer than 6

    Good catch on the asterisk and back-up copy, Tony.

    With regards to formulas, I've accounted for that by using Look In: Values.

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula to search all cells in a workbook for characters longer than 6

    I don't have a Look in Values option in any of my versions of Excel.
    Attached Images Attached Images

  14. #14
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Formula to search all cells in a workbook for characters longer than 6

    <DELETED>

    EDIT: Got it. I was looking at the wrong tab. OP, if those cells you want to find and replace are formulas, you might want to ignore my comments.
    Last edited by quekbc; 07-21-2015 at 07:22 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Text can be no longer than 80 characters
    By Chris_Pollinger in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 03-17-2014, 02:05 PM
  2. [SOLVED] Cells including unwanted characters (search formula?)
    By letangerang58 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-10-2013, 02:28 PM
  3. Replies: 6
    Last Post: 02-22-2012, 02:16 PM
  4. Pass text strings longer than 255 characters
    By carry in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-22-2011, 12:26 PM
  5. Replies: 7
    Last Post: 06-30-2010, 01:51 PM
  6. A Custom Sort List Longer Than 255 Characters?
    By minimagician in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2009, 07:09 PM
  7. [SOLVED] Binary numbers longer than 10 characters
    By Andibevan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-11-2005, 08:07 AM
  8. [SOLVED] Binary Numbers longer than 10 characters
    By Andibevan in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-06-2005, 07:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1