+ Reply to Thread
Results 1 to 5 of 5

Create unique client number (in increments of 1)

  1. #1
    Registered User
    Join Date
    12-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    39

    Exclamation Create unique client number (in increments of 1)

    Hi,

    I'm trying to generate a unique (arbitrary) client number for each client in a database, and ideally want to create a macro that does this for me. I've tried various formulas in the first instance, to no avail.

    What I would typically have is a database that includes the client name, after which I would need to create a new column (column A) to produce a unique client number for each client, i.e.:


    (Col A) (Col B)
    ClientNo Client Name
    1 Smith, John
    1 Smith, John
    1 Smith, John
    1 Smith, John
    1 Smith, John
    1 Smith, John
    2 Jones, Lisa
    2 Jones, Lisa
    2 Jones, Lisa
    3 Anthony, Sarah
    4 Baker, Joe
    4 Baker, Joe
    4 Baker, Joe



    Any ideas?

    Thank you in advance!

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

    Re: Create unique client number (in increments of 1)

    Here's a formula you could use in A2:

    =IF(B2="","",IF(B2=B1,A1,max(A$1:A1)+1))

    Copy down as far as you need to (or beyond if you want to accommodate new data being added).

    Hope this helps.

    Pete
    Last edited by Pete_UK; 10-16-2015 at 05:07 AM.

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Create unique client number (in increments of 1)

    Data Range
    A
    B
    1
    ClientNo
    Client Name
    2
    1
    Smith, John
    3
    1
    Smith, John
    4
    1
    Smith, John
    5
    1
    Smith, John
    6
    1
    Smith, John
    7
    1
    Smith, John
    8
    2
    Jones, Lisa
    9
    2
    Jones, Lisa
    10
    2
    Jones, Lisa
    11
    3
    Anthony, Sarah
    12
    4
    Baker, Joe
    13
    4
    Baker, Joe
    14
    4
    Baker, Joe

    Data Range
    A
    2
    =IF(B2="","",IF(COUNTIF($B$1:B1,$B2),INDEX($A$1:$A1,MATCH($B2,$B$1:$B1,0)),MAX($A$1:$A1)+1))


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Registered User
    Join Date
    12-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    39

    Re: Create unique client number (in increments of 1)

    Quote Originally Posted by :) Sixthsense :) View Post
    Data Range
    A
    B
    1
    ClientNo
    Client Name
    2
    1
    Smith, John
    3
    1
    Smith, John
    4
    1
    Smith, John
    5
    1
    Smith, John
    6
    1
    Smith, John
    7
    1
    Smith, John
    8
    2
    Jones, Lisa
    9
    2
    Jones, Lisa
    10
    2
    Jones, Lisa
    11
    3
    Anthony, Sarah
    12
    4
    Baker, Joe
    13
    4
    Baker, Joe
    14
    4
    Baker, Joe

    Data Range
    A
    2
    =IF(B2="","",IF(COUNTIF($B$1:B1,$B2),INDEX($A$1:$A1,MATCH($B2,$B$1:$B1,0)),MAX($A$1:$A1)+1))

    Thank you! That's worked perfectly.

  5. #5
    Registered User
    Join Date
    12-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    39

    Re: Create unique client number (in increments of 1)

    Quote Originally Posted by Pete_UK View Post
    Here's a formula you could use in A2:

    =IF(B2="","",IF(B2=B1,A1,max(A$1:A1)+1))

    Copy down as far as you need to (or beyond if you want to accommodate new data being added).

    Hope this helps.

    Pete
    Thanks for your reply; I appreciate it!

+ 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. [SOLVED] create a unique reference number
    By RIZVI in forum Excel Programming / VBA / Macros
    Replies: 30
    Last Post: 06-01-2015, 03:06 AM
  2. Replies: 4
    Last Post: 11-26-2014, 04:52 AM
  3. [SOLVED] Count unique items per client
    By Ricardo Mass in forum Excel General
    Replies: 5
    Last Post: 04-03-2014, 06:23 AM
  4. Replies: 1
    Last Post: 05-24-2012, 10:43 AM
  5. Replies: 7
    Last Post: 05-17-2012, 03:08 AM
  6. Replies: 5
    Last Post: 11-26-2008, 02:10 PM
  7. [SOLVED] Create a unique random number
    By Jack in forum Excel General
    Replies: 2
    Last Post: 04-19-2006, 04:20 PM

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