+ Reply to Thread
Results 1 to 7 of 7

function assistance please

  1. #1
    Registered User
    Join Date
    02-16-2007
    Posts
    2

    function assistance please

    Please help!

    I am trying to match data in one column to data in another using a formula, however what I have tried does not seem to give me correct results. Here is an example:

    COLUMN A COLUMN B
    01223343 01223343
    01223344 01223344
    01223345 01223345
    01223346 01223346
    01223348 01223347
    01223350 01223348

    I need to create a formula that indicates that a number in column A is also in column B, using an IF function so I can get a true or false result. The problem I have run into is that, as you see in my example above, the numbers do not necessarily match row for row. My original formula was: =IF(A2=(lookup(A2,b2:b100)),"True","False"). This appeared to work, until the number in cell A6 did not match the number in cell B6, then it came back false even though the number was clearly in the array. Ultimately I am trying get the result spelled out here: If this number is in this column then 'true', if not then 'false'

    Any help would be greatly appreciated!!

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    This site might help

    http://www.cpearson.com/excel/duplic...tractingUnique


    I suggest

    =IF(COUNTIF($A$1:$A$10,B1)>0,TRUE,FALSE)

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Try

    =IF(A2=(LOOKUP(A2,$B$2:$B$100)),"True","False")

    The $'s will keep the lookup range static. Without them, as the formula moves down rows it will change to "B3:B101", "B4:B102", etc.

    I plugged this into my sheet and it works fine.

  4. #4
    Registered User
    Join Date
    02-16-2007
    Posts
    2

    Thanks!!!!

    The suggestion from VBA Noob was the one that worked!!

    I wasn't too concerned with locking the range with the $$ signs since my data filled 8,000+ rows, although I appreciated the reminder to add them.

    I am not sure why the formula suggestion from pjoaquin didn't work since it does seem to be correct, but I did try it again and I ended up with the same results. For example, the number in cell A55 is 00116675 and I can see it in the lookup array($B$2:$B$1000) in cell B57, however this formula indicates "false" even though it is clearly "true". Funny, huh?! Thank you regardless, pjoaquin, I appreciate the effort!!!

    Also, thanks for the very quick responses! I told many co-workers about this site this afternoon. I am sure I will be in need again!

    Lisa

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Glad you got a solution

    Thx for the feedback

    VBA Noob

  6. #6
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    You mentioned the number is 00116675. In order to get the leading zeros, is this cell formatted as text? custom number format?

    I, too, wonder why the formula didn't work. One of life's great mysteries I suppose.

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,721
    LOOKUP needs the lookup range to be sorted ascending, otherwise the results may not be correct.

    COUNTIF is fine although you don't really need the IF

    =COUNTIF($A$1:$A$10,B1)>0

    This will give you TRUE or FALSE by default [although logical values not text values]

    ....another way, which is probably more efficient (perhaps not relevant here but might be if you had a huge spreadsheet with lots of such formulas)

    =ISNUMBER(MATCH(B1,$A$1:$A$10,0))

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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