+ Reply to Thread
Results 1 to 7 of 7

Preventing duplicate entry with COUNTIF

  1. #1
    Registered User
    Join Date
    08-16-2011
    Location
    Dexter, Michigan
    MS-Off Ver
    Excel 2010
    Posts
    5

    Preventing duplicate entry with COUNTIF

    I have a situation where a user will be entering data into column A in either HEX or DEC format. In column B, I am converting all entries to DEC.

    I want to be able to prevent a duplicate entry in column A, based on the result of the DEC conversion in column B.

    I have used this code in Validation before to deal with similar issues -

    =COUNTIF($A$1:A1,A1)=1

    This would work great if every entry was the same format, but in my situation, there could be two rows that have the "same" value, but one in HEX and one in DEC.

    If there is another solution unrelated to COUNTIF, I am open to any idea.



    Thanks in advance for any assistance.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Preventing duplicate entry with COUNTIF

    The COUNTIF() is the correct method, but you would do it on the column B, where the values entered in column A are being converted to the same format.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-16-2011
    Location
    Dexter, Michigan
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Preventing duplicate entry with COUNTIF

    Quote Originally Posted by JBeaucaire View Post
    The COUNTIF() is the correct method, but you would do it on the column B, where the values entered in column A are being converted to the same format.

    This does not seem to be working as I'd expect.

    I've attached a simple test sheet with some sample values.

    Duplicates in column A are not being caught as far as I can tell.
    Attached Files Attached Files

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Preventing duplicate entry with COUNTIF

    I didn't see your attempt at a custom Data Validation in column A based on a COUNTIF of column B.

    1) Highlight A1:A31
    2) Open Data Validation and apply the settings:

    List: Custom
    Source: =COUNTIF($B$1:$B1,$B1)<=1

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,628

    Re: Preventing duplicate entry with COUNTIF

    For validating you have used this formula in A1 cell
    =COUNTIF($A$1:A1,A1)=1

    Pl replace this by this formula below and copy validation to other cells.

    =COUNTIF($B$1:B1,(IF(ISERROR(INT(A1)),TEXT(HEX2DEC(A1),"00000000000"),A1)))<=1
    Pl convey your result.

  6. #6
    Registered User
    Join Date
    08-16-2011
    Location
    Dexter, Michigan
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Preventing duplicate entry with COUNTIF

    Thanks for the help guys, the second solution from kvsrinivasamurthy worked exactly as I needed.

    I could not get the other suggestion to work, validation doesn't seem to work on a cell that hasn't been generated yet by a formula (?). Including the conversion inside the validation formula worked.


    In any event, this is resolved, so thanks to you both for the assistance.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Preventing duplicate entry with COUNTIF

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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