+ Reply to Thread
Results 1 to 9 of 9

Logical Test

  1. #1
    Registered User
    Join Date
    06-26-2012
    Location
    Limerick, Ireland
    MS-Off Ver
    Excel 2016
    Posts
    52

    Logical Test

    Hi,

    I have a rows of data starting from A5:A500, the data in each cell has 10 characters (123456789A). In cell B5, i have used the following formula =LEFT(A5,4), as i'm only interested in the first 4 characters (these should be the same for all entries in A5:A500 (1234)). So far no problem, now in C5, I have entered my logical test =IF($F$1=B5,1,0), here is where the problem is, both B5 (1234) and F1 (1234) have the same data visually, I have ensured that both cells are formatted in number format, i even checked character lenght by using a formula, both have the same lenght.

    Is the formula I have used in B5 not suitable in this case as when i manually type 1234 into B5 my logical test formula works

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,956

    Re: Logical Test

    Can we see the workbook, please?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Logical Test

    In B5, use =--LEFT(A5,4)
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Logical Test

    The LEFT function returns a string result, so you can't compare that directly with a number in F1. You can either precede the number in F1 with an apostrophe (i.e. enter it as '1234 - the apostrophe won't show in the cell), which will turn that into a text value, or you can format the cell F1 as Text, or you can amend your formula in B5 to this:

    =--LEFT(A5,4)

    which will turn that result into a number.

    Hope this helps.

    Pete

  5. #5
    Registered User
    Join Date
    06-26-2012
    Location
    Limerick, Ireland
    MS-Off Ver
    Excel 2016
    Posts
    52

    Re: Logical Test

    Thanks Guys the =--Left(A5,4) worked.

  6. #6
    Registered User
    Join Date
    06-26-2012
    Location
    Limerick, Ireland
    MS-Off Ver
    Excel 2016
    Posts
    52

    Re: Logical Test

    Quote Originally Posted by Pete_UK View Post
    The LEFT function returns a string result, so you can't compare that directly with a number in F1. You can either precede the number in F1 with an apostrophe (i.e. enter it as '1234 - the apostrophe won't show in the cell), which will turn that into a text value, or you can format the cell F1 as Text, or you can amend your formula in B5 to this:

    =--LEFT(A5,4)

    which will turn that result into a number.

    Hope this helps.

    Pete
    Hi Pete,

    I now have a value which consists of both numerical and text characters, when I use formula =--LEFT(A5,4) it returns a #value! error, but when I remove the -- in the logical formula and insert ' before the look up value in F1 it works. Is it possible to modify the logical test formula for where alphanumerical values are used, as i don't want to have to modify the value in F1

    Thanks,
    Brian.

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Logical Test

    I think the easiest solution is to format cell F1 as Text, so that anything you put in there will be treated as a text value and you don't have to use a leading apostrophe, even for pure numbers. Then you can just use =LEFT(A5,4) in B5 to cope with all cases.

    If you really want to keep F1 formatted as General, then you would need to do something like this in B5:

    =IF(ISNUMBER($F$1*1),--LEFT(A5,4),LEFT(A5,4))

    Hope this helps.

    Pete

  8. #8
    Registered User
    Join Date
    06-26-2012
    Location
    Limerick, Ireland
    MS-Off Ver
    Excel 2016
    Posts
    52

    Re: Logical Test

    Thanks Pete reformatting of the cells worked great, thanks for your help

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,423

    Re: Logical Test

    Glad to be of help.

    If that takes care of your original question, please select Thread Tools from the menu above your first post and mark this thread as SOLVED.

    Also, since you are relatively new to the forum, I would like to inform you that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

+ 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. Logical test false values skip to next row for next test
    By Schecter89 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-23-2018, 06:36 AM
  2. IF logical test
    By Jszota in forum Excel General
    Replies: 1
    Last Post: 06-24-2011, 10:07 AM
  3. logical test
    By LisaD in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-08-2006, 10:30 AM
  4. [SOLVED] Logical Test
    By Lance in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-16-2006, 05:30 PM
  5. Logical test
    By Sooraj in forum Excel General
    Replies: 2
    Last Post: 01-25-2005, 09:06 AM

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