Need a macro??
-
- 5StarLounger
- Posts: 627
- Joined: 03 Feb 2010, 15:02
Need a macro??
I have a column of client numbers in B. I want to create a another column where it names each of the client numbers - Client 1, Client 2 and so on until it comes to a client number that repeats itself then I want for instance Client 10, Client 10 etc until it comes to another number then start back with Client 11 so on and so forth. I am doing this manually but the report is increasing in size. Every time I refresh the file, I have to create the Client 1, Client 2 column. Any help would be appreciated.
-
- Administrator
- Posts: 78598
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Need a macro??
If the client numbers in column B are sorted in ascending order, you can use an easy formula.
Let's say that the client numbers start in B2.
In C2, enter 1.
In C3, enter =C2+(B3>B2)
Fill down as far as needed.
If you want to see "Client 1" etc., format C2 and down with the custom number format "Client "0
Let's say that the client numbers start in B2.
In C2, enter 1.
In C3, enter =C2+(B3>B2)
Fill down as far as needed.
If you want to see "Client 1" etc., format C2 and down with the custom number format "Client "0
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 392
- Joined: 25 Jan 2010, 12:21
Re: Need a macro??
If the list in B may or may not be sorted, in C2 you could use something like:
=IF(COUNTIF(B$1:B1,B2)=0,MAX(C$1:C1)+1,VLOOKUP(B2,B$1:C1,2,0))
[and Custom format as Hans suggested]
Steve
=IF(COUNTIF(B$1:B1,B2)=0,MAX(C$1:C1)+1,VLOOKUP(B2,B$1:C1,2,0))
[and Custom format as Hans suggested]
Steve
-
- 5StarLounger
- Posts: 627
- Joined: 03 Feb 2010, 15:02
Re: Need a macro??
Worked perfectly. The column is sorted. Thank you both. I probably will use both suggestions in the future. What a time saver.