+ Reply to Thread
Results 1 to 4 of 4

Checking for duplicates & assigning assending letters in next colomn before sort

  1. #1
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2013 / 2016
    Posts
    69

    Checking for duplicates & assigning assending letters in next colomn before sort

    Hi,
    I hope someone can help as I’m trying to learn a bit of VBA.
    I’m trying to do 2 things with the example below in my new database….
    1. Add a row to the bottom of the table through a user form I assign a log number (Col A), I need VBA to look & see if that number already exists & if it does assign a letter in col B starting with b & then c etc (If no match no value in Col B), then combine the 2 values in column c then sort as in the example on the right.
    2. Need to ensure there can’t be duplicates from the 2 combined columns (A & B).

    Can it be done?

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 02-18-2013 at 11:01 AM.

  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: Checking for duplicates & assigning assending letters in next colomn before sort

    No need for column B, put this in C2 and copy down:

    =IF(COUNTIF($A$1:$A2, $A2)=1, $A2, $A2 & " " & CHAR(65+COUNTIF($A$1:$A1, $A2)))
    _________________
    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
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2013 / 2016
    Posts
    69

    Re: Checking for duplicates & assigning assending letters in next colomn before sort

    Quote Originally Posted by JBeaucaire View Post
    No need for column B, put this in C2 and copy down:

    =IF(COUNTIF($A$1:$A2, $A2)=1, $A2, $A2 & " " & CHAR(65+COUNTIF($A$1:$A1, $A2)))
    Ah, that worked by assigning the letters as required but it doesnt sort the way I need it (see below), I'm probably missing something!!

    A B
    100 100
    101 101
    102 102
    103 103
    104 104
    105 105

    102 102 B
    102 102 C
    Last edited by How How; 02-18-2013 at 11:50 AM.

  4. #4
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2013 / 2016
    Posts
    69

    Re: Checking for duplicates & assigning assending letters in next colomn before sort

    Sorry JB, I had a senior moment & was sorting in the wrong order!!!


    It works perfectly!!

    Thanks

+ 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