Sequential number within excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please see the data below

a b c
000000080672 EI0G18 1.00
EIVH38 1.00
EIVK38 1.00
000000082585 EIRH69 1.00
EIRK69 1.00

the first 3 items in column B belongs to the first item in column a.
Accordingly the next 2 items in col "b" belongs to the next item in col "A".
I want to number the first item in col "A" as 1 and the 3 items in col "B" as
1.1, 1.2 1.3 and accordingly, the next item in col "a" as number 2 and
accordingly the item 4 and 5 in col "b" as 2.1 & 2.2 and so on.....
 
Sub number_items()
Dim imajor As Long, iminor As Long
Dim rng As Range, cell As Range
imajor = 0
iminor = 0
Set rng = Range(Cells(1, "B"), _
Cells(Rows.Count, "B").End(xlUp))
For Each cell In rng
If Not IsEmpty(cell.Offset(0, -1)) Then
imajor = imajor + 1
iminor = 1
End If
cell.Offset(0, 2).Value = "'" & imajor _
& "." & iminor
iminor = iminor + 1
Next
End Sub

Test this on a copy of your data. I assume the 1.0 are in column C. and
column a has some blank cells in it (your labels in the post are a little
off).
 
Using Formulas it Would look something like this:
Columns D
=IF(ROW()=2;1;IF(A2<>"";D1+1;D1))
Column E
= IF(ROW()=2;1;E1+1)
Column F
= D2&"."&E2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top