+ Reply to Thread
Results 1 to 4 of 4

Using LEFT function to extract value

  1. #1
    Registered User
    Join Date
    01-07-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    64

    Using LEFT function to extract value

    Hi,

    I have a spreadsheet where I am searching by break numbers (there is two kinds of break numbers: 5 digit ones and seven digit ones). I have a search engine at the top which searches through records for certain information and returns the rows with the according information. For the break numbers search, the user types in a number, and the search engine checks whether it is between two numbers, and then returns the rows where the number typed exists between the range. In my spreadsheet, if the user typed in 70032, the search engine would return all rows where that number exists:

    C1 C2
    R3: 70000 71000
    R6: 70000 70500

    However, because I am using the LEFT function, what the search engine is actually doing is the following:

    C1 C2
    R3: 70000 71000
    R6: 70000 70500
    R10: 7000001 7005000

    It is returning the rows with the seven digit numbers as well. Is there any way to fix this issue, as in if a user typed in a five digit number, it would only return rows with five digit number?

    This is the formula that I have so far in order to check whether a number is within a range (_G5 is the cell where user types in the number, and C1 and C2 are the columns which contain the lower and higher end of the range) :

    AND(--(LEFT(C1, LEN(_G5)))<=_G5,--(LEFT(C2, LEN(_G5)))>=_G5

    Any help would be appreciated.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Using LEFT function to extract value

    Can't you just check that the _G5 number is between C1 and C2?

    =AND(_G5>=C1,_G5<=C2)
    Audere est facere

  3. #3
    Registered User
    Join Date
    01-07-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: Using LEFT function to extract value

    I just tried that, and I typed in 70032 into _G5, and now this is what I am getting:

    C1 C2
    R3: 70000 71000
    R5: 70000 70500
    R7: 60000 64500
    R8: 28000 28117

    Basically, now all the numbers are of the same digits and the rows returned have the same number of digits as the number in _G5, but it is not returning the rows where the number is within range.

  4. #4
    Registered User
    Join Date
    01-07-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: Using LEFT function to extract value

    Never mind! I just made a tiny mistake! It works fine now with the formula you suggested! Thanks!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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