Hi,
I need to generate number into column F, based on hierarchy (col B:D), below is excel examaple:
<tbody>
</tbody>
I know only how to set A1, B1 and C1 value.
I need to generate number into column F, based on hierarchy (col B:D), below is excel examaple:
A | B | C | D | E | F |
1 | |||||
2 | Looking Numbers | ||||
3 | A1 | 1 | |||
4 | A1.1 | 101 | |||
5 | A1.2 | 201 | |||
6 | A1.3 | 301 | |||
7 | A1.3.1 | 10301 | |||
8 | |||||
9 | B1 | 2 | |||
10 | B1.1 | 102 | |||
11 | B1.2 | 202 | |||
12 | B1.2.1 | 10202 | |||
13 | B1.2.2 | 20202 | |||
14 | B1.3 | 302 | |||
15 | B1.4 | 402 | |||
16 | |||||
17 | C1 | 3 | |||
18 | C1.1 | 103 | |||
19 | C1.1.1 | 10103 | |||
20 | C1.1.2 | 20103 |
<tbody>
</tbody>
I know only how to set A1, B1 and C1 value.
Code:
ws_c = ws1.Cells(Rows.Count, "D").End(xlUp).Row
Dim Lev1, Lev2, Lev3 As Long
Lev1 = 1
For i = 3 To ws_c
If ws1.Range("B" & i).Value <> "" Then
ws1.Range("F" & i).Value = Lev1
Lev1 = Lev1 + 1
End If
Next
Last edited: