+ Reply to Thread
Results 1 to 11 of 11

How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

  1. #1
    Registered User
    Join Date
    11-30-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    69

    How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

    This I think should be easy for any pro. I tried searching online but couldn't find the answer.

    The following formula below is what I am using to compare the first word of two cells. However, if one cell doesn't have two words, meaning there won't be a space after the word, I get the #VALUE! error instead of the false portion of the formula being executed. How can I fix this?

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

    Try this, instead:

    =IF(AND(ISNUMBER(SEARCH(" ",B1)),ISNUMBER(SEARCH(" ",B2))),"Same","Diff")
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

    On reflection, it might be "safer" to use this:

    =IF(AND(ISNUMBER(SEARCH(" ",TRIM(B1))),ISNUMBER(SEARCH(" ",TRIM(B2)))),"Same","Diff")

    which will eliminate stray leading/trailing spaces.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

    You would get the error if no space is found,
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    if no space in B1 then you will get the error. The search function is telling you where the space is, if no space, it can't give you a value.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-30-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    69

    Re: How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

    Quote Originally Posted by Glenn Kennedy View Post
    On reflection, it might be "safer" to use this:

    =IF(AND(ISNUMBER(SEARCH(" ",TRIM(B1))),ISNUMBER(SEARCH(" ",TRIM(B2)))),"Same","Diff")

    which will eliminate stray leading/trailing spaces.
    Thanks, but this only works if I am either 1) applying it to the cell reference that I know will give the error (in my case it's only the header / B1) or 2) or dealing with cells that only have numbers.

    I am comparing text.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

    Roseuz, who are you talking to?

  7. #7
    Registered User
    Join Date
    11-30-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    69

    Re: How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

    Quote Originally Posted by davesexcel View Post
    You would get the error if no space is found,
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    if no space in B1 then you will get the error. The search function is telling you where the space is, if no space, it can't give you a value.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I was just about getting ready to update this to show that I found out that one can use the IFERROR statement, when I saw you had already posted this response.

    Thank you.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

    See the attached file.

    I think that YOU need to post a sample file, showing a range of expected results.
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,911

    Re: How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

    Maybe?

    =IF(LEFT(B2,SEARCH(" ",B2&" ",1)-1)<>LEFT(B1,SEARCH(" ",B1&" ",1)-1),"Diff","Same")

  10. #10
    Registered User
    Join Date
    11-30-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    69

    Re: How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

    Quote Originally Posted by Glenn Kennedy View Post
    See the attached file.

    I think that YOU need to post a sample file, showing a range of expected results.
    I simply applied the ISNUMBER function to one portion (the portion that looks at the cell with only one word) and it worked. I then applied it to the second portion and it didn't. Now upon studying this further, I see that you swapped the positions of the "DIFF" and "SAME" in your formula. When I do that, I then get the correct results.

    I have attached a file showing the results.
    Attached Files Attached Files

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: How to Handle the #VALUE! Error when Comparing Cells (One word / No Space after word)?

    God, I'm confused now. You really don't believe in making things clear, do you???

    What are your expected results in the 3 cases on the example sheet?

+ 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. [SOLVED] handle file between Word & Excel in VBA
    By Ethen5155 in forum Word Programming / VBA / Macros
    Replies: 17
    Last Post: 01-15-2017, 03:28 AM
  2. Replies: 5
    Last Post: 10-02-2016, 03:03 PM
  3. Is there a word macro to help me (1) combine different word files and (2) add space?
    By studyboymark in forum Word Programming / VBA / Macros
    Replies: 0
    Last Post: 03-05-2015, 03:19 AM
  4. Replies: 2
    Last Post: 10-30-2014, 01:49 AM
  5. Hiding table's handle in Word 2007
    By florence in forum Word Formatting & General
    Replies: 6
    Last Post: 09-11-2010, 04:43 PM
  6. Replies: 13
    Last Post: 05-06-2009, 07:33 AM
  7. Import cells from excel into word and create multiple word docs
    By scdaddy7269 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2006, 03:03 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