+ Reply to Thread
Results 1 to 14 of 14

unable to return duplicate value

  1. #1
    Registered User
    Join Date
    02-23-2010
    Location
    asd
    MS-Off Ver
    Excel 2003
    Posts
    27

    unable to return duplicate value

    Hi expert,
    how to create a formula based on below situation:


    Please Login or Register  to view this content.
    i would like to return E6 =1 and E7 = 2..
    the logic above is like this...
    1) if B only appear once (no duplicate), return E=1
    2) if B appear more than once ( duplicate) , but C = value (ex: -10), return E =1, else E=2.
    3)if B appear more than once ( duplicate) and C = no value (ex: NA), return the first as 1, second as 2.


    from the formula in column E, logic 1 and 2 is ok.. but.. for logic 3.. is not OK.. i want to return E7 ( red font to 1), but it return 2.

    please advice..
    Last edited by celticpucca; 02-10-2011 at 04:50 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: unable to return duplicate value

    I'd first suggest inserting a blank row 1 to simplify calcs...

    Then assuming value is now in B2 rather than B1

    Please Login or Register  to view this content.
    this would return

    Please Login or Register  to view this content.
    I believe the first two NA references should both be returning 1 as both are first instances of that no.

    If necessary post back with a sample file.

  3. #3
    Registered User
    Join Date
    02-23-2010
    Location
    asd
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: unable to return duplicate value

    Hi,
    i had attached the exmaple..
    i would like to return the red cells into 1..
    if cell A appear only one, B= 1, if cell A appear more than 1 and cell C = value ( ex: -123), return B =1, else = 2, if cell A appear more than 1 and cell C= NA, return B = 1 ( ex: red cell) and else = 2
    Attached Files Attached Files
    Last edited by celticpucca; 02-10-2011 at 08:04 AM.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: unable to return duplicate value

    Using the sample file:

    Please Login or Register  to view this content.
    However, I don't understand why B3 should be 2 - it should be 1 surely given it too is the first #N/A for that OPN

  5. #5
    Registered User
    Join Date
    02-23-2010
    Location
    asd
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: unable to return duplicate value

    hi,
    B3 should be 2 because it same as B2 but C3 = NA.
    i want to return 1 if OPN =1, OPN <>1 and CMD = value. and if OPN<>1 and CMD = NA, retrun the fisrt 1, next 2.

    the code posted work..!!! but... B3 = 1 where it shud be 2...
    kindly advise..

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: unable to return duplicate value

    Your requirements appear contradictory:

    Quote Originally Posted by celticpucca post#1
    if B appear more than once ( duplicate) and C = no value (ex: NA), return the first as 1, second as 2.
    Quote Originally Posted by celticpucca post#5
    B3 should be 2 because it same as B2 but C3 = NA.
    Per your first quote (requirement) given B3 is the first "no value" for duplicate of "OPN" value in A3 the resulting value should be 1 not 2.

    For your 2nd quote to hold true and all other results to persist the implication would be that:

    Where OPN is duplicate and has >1 "no value" the first "no value" should be 1 else 2.

    If that's the case please affirm as such.

  7. #7
    Registered User
    Join Date
    02-23-2010
    Location
    asd
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: unable to return duplicate value

    hi..
    sorry.. maybe im not good in explaning...

    if B appear more than once ( duplicate) and C = no value (ex: NA), return the first as 1, second as 2
    my goal is to :
    1) Return OPN that appear only one to 1 ( ex: A4,A7,A8,A9,A10,A15 and A16)
    2) if OPN return more than one, return 1 to OPN that have CMD value. ( Ex: A2 = A3, A11=A12, CMD value available at A2 and A11, so, return 1 at A2 and A11
    3) but, if the OPN return more than 1 and all of this OPN dont have CMD value ( NA), i want to return the 1st OPN to 1 and 2nd OPN to 2.( example: A5 = A6, A13 = A14 and dont have CMD value, return 1 to A5 and A13.)

    hope this explanation can help u to understand my requirement....
    thank you... kindly advise....

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: unable to return duplicate value

    Are the OPN items always listed in sequence ?

    Will an OPN ever appear more than twice ?

    Assuming answers to above are Yes & No respectively:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-23-2010
    Location
    asd
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: unable to return duplicate value

    Are the OPN items always listed in sequence ? = YES

    Will an OPN ever appear more than twice ? = NO

    the code worked perfectly...!!! thanks a lot..!!!!!

  10. #10
    Registered User
    Join Date
    02-23-2010
    Location
    asd
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: unable to return duplicate value

    DonkeyOte..!!!

    sorry.. i check my file and :

    Will an OPN ever appear more than twice ? = YES... sometimes it appear 3 - 5 times.. but only one of it have CMD value....


    sorry.... i misslook it..please advise....

  11. #11
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: unable to return duplicate value

    Quote Originally Posted by celticpucca
    sometimes it appear 3 - 5 times.. but only one of it have CMD value....
    Is the CMD value always listed first ? (where exists), eg:

    Please Login or Register  to view this content.
    or can you have

    Please Login or Register  to view this content.
    Where you have > 2 OPN for which no CMD values exist what is the numbering sequence - consider:

    Please Login or Register  to view this content.
    should the resulting output be

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    or something else altogether ?

    Please provide sample file as necessary.

  12. #12
    Registered User
    Join Date
    02-23-2010
    Location
    asd
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: unable to return duplicate value

    Hi DonkeyOte,

    i attached the whole data.. kindly refer to example 2 worksheet.

    hope this can help u to understand my requirement....


    Thanks....
    Attached Files Attached Files

  13. #13
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: unable to return duplicate value

    Given XL version etc and the facts that
    1. the CMD value does not necessarily appear first
    2. the number of OPN instances is variable
    3. some OPN values are stored as numbers whereas others are stored as text
      (ie not really sorted A-Z)

    I'd suggest first adding a "key":

    Please Login or Register  to view this content.
    Then:

    Please Login or Register  to view this content.
    In the above the COUNTIF will only be calculated in those instances where the first instance of a given OPN has an #N/A CMD value

  14. #14
    Registered User
    Join Date
    02-23-2010
    Location
    asd
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: unable to return duplicate value

    DonkeyOte.....

    work as just i need... thanks a lot.....

+ 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