Putting serial no. on column

RahulNa

Board Regular
Joined
Jul 12, 2012
Messages
124
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am having an excel data where a serial number is required based on a particular column value.

Serial NumberBatchNew Serial Number
1010869GN91
2053332AR32
3785870XE13
446625HJT8344
5010869GN9
676886PES85
7785870XE1
8053332AR3

<tbody>
</tbody>


I want when the first batch number comes there should be a serial number accordingly to it. Even if it get repeated many times there should be only 1 serial number on the first instance.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
place code into a module , then run BuildSerials


Code:
Sub BuildSerials()
Dim col As New Collection
Dim sBatch
Dim iSer As Long


On Error GoTo errCol


iSer = 1
Range("B2").Select
While ActiveCell.Value <> ""
   sBatch = ActiveCell.Value
   col.Add sBatch, sBatch
   ActiveCell.Offset(0, 1).Value = iSer
   iSer = iSer + 1
   
skipAdd:
   ActiveCell.Offset(1, 0).Select
Wend
Set col = Nothing
Exit Sub
errCol:
Resume skipAdd
End Sub
 
Upvote 0

Excel 2010
ABC
1Serial NumberBatchNew Serial Number
21010869GN91
32053332AR32
43785870XE13
5446625HJT8344
65010869GN9
7676886PES85
87785870XE1
98053332AR3
Sheet25
Cell Formulas
RangeFormula
C3=IF(COUNTIF($B$2:B3,B3)<>1,"",LOOKUP(2,1/($C$2:C2<>""),$C$2:C2)+1)
 
Upvote 0
OR, with a formula, no VBA, assuming your first batch number is held in cell B2 . . .

In C2 . . .
=IF(COUNTIF(B$1:B2,B2)=1,MAX(C$1:C1)+1,"")

and copy all the way down.
 
Upvote 0
Excel 2010
ABC
1Serial NumberBatchNew Serial Number
21010869GN91
32053332AR32
43785870XE13
5446625HJT8344
65010869GN9
7676886PES85
87785870XE1
98053332AR3

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet25

Worksheet Formulas
CellFormula
C3=IF(COUNTIF($B$2:B3,B3)<>1,"",LOOKUP(2,1/($C$2:C2<>""),$C$2:C2)+1)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top