Create a numbering system by levels

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,368
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I posted this question years ago and have a need to use it again. I'm specifically asking about the macro in post #7.

If you want, you can use a Level number of 0 at any time (including at the start of the Level list) to start a new, non-dotted (chapter) Number sequence (that is, a 1 or 2 or 3 etc.). If you start the Level list with 0, then the (chapter) Number list will start with 1; if you start the Level list with 1, then the (chapter) Number list will start with 1.1; if you start the Level list with 2, then the (chapter) Number list will start with 1.1.1; etc

In reading this note, I would think I could change something in the code to start the list with a 1 as seen in column T. Column T are the results I would like based on the level in Column R.

Data Range
R​
S​
T​
1​
Level​
2​
1​
1.1​
1​
3​
2​
1.1.1​
1.1​
4​
3​
1.1.1.1​
1.1.1​
5​
3​
1.1.1.2​
1.1.2​
6​
2​
1.1.2​
1.2​
7​
3​
1.1.2.1​
1.2.1​
8​
3​
1.1.2.2​
1.2.2​
9​
2​
1.1.3​
1.3​
10​
3​
1.1.3.1​
1.3.1​
11​
3​
1.1.3.2​
1.3.2​
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I have made a formula based solution, mostly for fun of doing it.

Columns B-E describe how it has been done, column F contains a single formula solution composed from them, plus on IF to make it blank when column A contains a blank.
The solution does not handle jumps, e.g., when after R=2 you immediately put R=4, omitting R=3. I assume that you never want to do that.

You can experiment with it here.

J.Ty.

Book1
ABCDEF
1Rrow of the most recent changerow of the most recent reset to 0increments sice the most recent resetcountercomplete counter with blank support
2100111
322211.11.1
433311.1.11.1.1
534321.1.21.1.2
635331.1.31.1.3
746611.1.3.11.1.3.1
823221.21.2
938811.2.11.2.1
10120222
112101012.12.1
123111112.1.12.1.1
134121212.1.1.12.1.1.1
143121122.1.22.1.2
154141412.1.2.12.1.2.1
Sheet1
Cell Formulas
RangeFormula
B2:B15B2=MAX(ROW(A$1:A1)*(A$1:A1<=A2))
C2:C15C2=MAX(ROW(A$1:A1)*(A$1:A1<A2))
D2:D15D2=COUNTIF(INDEX(A$1:A1,C2):A2,A2)
E2:F2E2="1"
E3:E15E3=IF(A3=1+A2,E2&".1",LEFT(INDEX(E$1:E2,B3),LEN(INDEX(E$1:E2,B3))-LEN(D3-1))&D3)
F3:F15F3=IF(ISBLANK(A3),"",IF(A3=1+A2,F2&".1",LEFT(INDEX(F$1:F2,MAX(ROW(A$1:A2)*(A$1:A2<=A3))),LEN(INDEX(F$1:F2,MAX(ROW(A$1:A2)*(A$1:A2<=A3))))-LEN(COUNTIF(INDEX(A$1:A2,MAX(ROW(A$1:A2)*(A$1:A2<A3))):A3,A3)-1))&COUNTIF(INDEX(A$1:A2,MAX(ROW(A$1:A2)*(A$1:A2<A3))):A3,A3)))
 
Upvote 0
Hi J.TY.,

Thank you for your help here, but I decided to go with this call at the end of the macro. Works well.

VBA Code:
Sub ReplaceFirstTwo()
    Dim Cell As Range
    For Each Cell In Range("S2", Range("S" & Rows.Count).End(xlUp))
        Cell.Value = Mid(Cell, 3, Len(Cell))
    Next Cell
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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