+ Reply to Thread
Results 1 to 16 of 16

Wrong value returned

  1. #1
    Registered User
    Join Date
    10-01-2018
    Location
    Ottawa
    MS-Off Ver
    Office 365
    Posts
    57

    Wrong value returned

    I have a text string equation that works very well, but it has a flaw. When I want to find the word college or collège from a range and return collège into another column, it seems to return college when it also finds a part of the word ie. Co as well. How do I fix this?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,436

    Re: Wrong value returned

    It would help if you told us what the foormula is and ...

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-01-2018
    Location
    Ottawa
    MS-Off Ver
    Office 365
    Posts
    57

    Re: Wrong value returned

    This is my equation

    =IFERROR(LOOKUP(19566,(SEARCH(Varanges18!$C$19:$C$45,V4)),Varanges18!$D$19:$D$45),"")
    Keywords and return are arranged into two separate columns


    Keyword Return
    BAFF Université
    Campus Campus
    CFMNB Université
    Chair Université
    Chaire Université
    CAN Collège
    College Collège
    Collège Collège
    Collégial Collège
    Faculté Université
    Faculty Université
    Graduate Université
    Institut Institut
    Institute Institut
    Institutes Institut
    Instituts Institut
    La Cité Collège
    NAIT Collège
    NSCC Collège
    Observatory Université
    Observatoire Université
    Polytechnic Collège
    Polytechnique Collège
    Undergraduate Université
    Universitaire Université
    Université Université
    University Université

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,436

    Re: Wrong value returned

    I repeat ...

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  5. #5
    Registered User
    Join Date
    10-01-2018
    Location
    Ottawa
    MS-Off Ver
    Office 365
    Posts
    57

    Re: Wrong value returned

    I had to break up the file several times it was too big. The equation which is problematic is in B column. I understand that the equation picks up not an exact match. For example, I wish to pick up "CAN" only, but it picks up Duncan, and this is not right. I understand that asterix wildcards are useful in a search for one value, but cannot figure out how to do it in a range.

    =IFERROR(LOOKUP(19566,(SEARCH(Varanges18!$A$2:$A$28,G4)),Varanges18!$B$2:$B$28),"")
    Attached Files Attached Files
    Last edited by alecoute; 02-02-2019 at 02:03 PM. Reason: Lack of clarity

  6. #6
    Registered User
    Join Date
    10-01-2018
    Location
    Ottawa
    MS-Off Ver
    Office 365
    Posts
    57

    Re: Wrong value returned

    Hi TMS,

    Is this a complicated equation to set up. I got the feel that I am missing something quite minor and yet have spent the night trying to figure it out without success. Would really appreciate help.

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Wrong value returned

    See if this works.

    =IFERROR(LOOKUP(2,1/SEARCH(" "&Varanges18!$C$19:$C$45&" "," "&SUBSTITUTE(G4,","," ")&" "),Varanges18!$D$19:$D$45),"")

  8. #8
    Registered User
    Join Date
    10-01-2018
    Location
    Ottawa
    MS-Off Ver
    Office 365
    Posts
    57

    Re: Wrong value returned

    Thank you so much. Will look at this tomorrow morning!

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,436

    Re: Wrong value returned

    Seems to work for me. I've changed entries to see if it picks them up dynamically and all changes were reflected.

    Does it work for you?

  10. #10
    Registered User
    Join Date
    10-01-2018
    Location
    Ottawa
    MS-Off Ver
    Office 365
    Posts
    57

    Re: Wrong value returned

    It works really well thank you. It's a totally different formula than I expected. I had thought we would be using wildcards. I would like to understand that formula better. Can you describe it?

    Again thank you very much.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,436

    Re: Wrong value returned

    Thanks for the rep.


    Obviously, the thanks for the solution go to jason.b75

    @jason.b75: thanks for following up for me

  12. #12
    Registered User
    Join Date
    10-01-2018
    Location
    Ottawa
    MS-Off Ver
    Office 365
    Posts
    57

    Re: Wrong value returned

    Hi Jason,

    Thank you very much for the the great equation.

  13. #13
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Wrong value returned

    Breaking the formula down a bit for you so you can see how it works.

    =IFERROR(LOOKUP(1e+100,SEARCH(" "&Varanges18!$C$19:$C$45&" "," "&SUBSTITUTE(G4,","," ")&" "),Varanges18!$D$19:$D$45),"")

    The bit in bold is adding a space to the beginning and end of each keyword in varanges18.
    The bit that is underscored adds a space to the beginning and end of the text in G4, it also substitutes commas in G4 with spaces, so that every word in G4 has at least one space before and after. Doing this to look for keywords surrounded by spaces eliminated errors such as "CAN" being incorrectly matched to "Canada"

    The other functions remain the same as your original formula, the method of LOOKUP(2,1/ is a habit for eliminating anything that returns a result of FALSE / zero, but it is not needed here, any number will suffice as long as it is greater than the number of characters in column G.

  14. #14
    Registered User
    Join Date
    10-01-2018
    Location
    Ottawa
    MS-Off Ver
    Office 365
    Posts
    57

    Re: Wrong value returned

    Thank you. I thought it was "*"& at the beginning.

    Do I need the 1e+100,SEARCH as your original formula did not include it =IFERROR(LOOKUP(2,1/SEARCH(" "&Varanges18!$C$19:$C$45&" "," "&SUBSTITUTE(G4,","," ")&" "),Varanges18!$D$19:$D$45),"")

    The way your equation is written, would it exclude a comma before or after "CAN"?

    When you say any number will suffice as long as it is greater than the number of characters in column G ( do you mean rows or the number of characters in the largest cell entry in column G?

    I am learning. Thanks again.

  15. #15
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Wrong value returned

    "*" is a wildcard character, with the SEARCH function, wildcards are not needed because it does a partial search anyway, by using " " you are looking for an actual space rather than just anything.

    1e+100, 2,1/ or 1234 will all do the same in this case, you can use any version. The first is just a very big number (1 followed by 100 0's). 2,1/ converts the results fromn the search to decimals, so the highest number ever found should be 1. 2 us just used as failsafe. With the exception of 2,1/, the numebr just needs to exceed the number of characters in the largest cell.

    "CAN" will match up to " CAN " ",CAN " ",CAN," or " CAN," but nothing else, for example " CAN." will not match beacuse of the period after CAN which is not allowed for.

  16. #16
    Registered User
    Join Date
    10-01-2018
    Location
    Ottawa
    MS-Off Ver
    Office 365
    Posts
    57

    Re: Wrong value returned

    Thanks teach!

    Alex

+ 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] Macro exporting and saving the wrong page with wrong name
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2018, 01:24 PM
  2. [SOLVED] Lookup formula, wrong values returned
    By TOM5491 in forum Excel - New Users/Basics
    Replies: 6
    Last Post: 12-14-2017, 06:56 PM
  3. [SOLVED] Wrong formula or wrong function?
    By cpope in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-08-2017, 10:27 AM
  4. [SOLVED] if statement help please. Wrong value being returned.
    By Mechjo16 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-26-2013, 10:29 PM
  5. [SOLVED] Run-time error '424': Wrong value returned
    By zbor in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-08-2012, 08:14 AM
  6. wrong date returned on ws.Cells(r,c).value
    By sbvb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-24-2005, 10:59 AM
  7. Wrong result returned by UsedRange.Rows.Count
    By j in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2005, 04:05 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