Increment number in Table (without reacting to sort)

Kamolga

Well-known Member
Joined
Jan 28, 2015
Messages
1,185
Hi,

I have a risks log table where the first column is just 1,2,3,4. but this column looks now like 3,1,4,2 because we sorted on a ranking or a category.
View attachment 45781
When a user needs to add a risk to the log, he should just manually add the next number (here 20 is easy but some files have hundreds) if the table is not sorted on the column number.

I could set a formula counting table rows above +1 or taking the max value of range above +1 but that number would then change for each line (risk #3 could become risk #1) whenever we would sort the table differently.

Any idea?

Thanks
 

Attachments

  • Capture.JPG
    Capture.JPG
    84.7 KB · Views: 13

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
How about a macro that will increment Column A under these conditions

1. The user enters a value in Column B
2. The cell in Column A is blank
3. The cell directly above the cell in Column B where the user entered the data is NOT blank

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 2 And Target.Offset(0, -1).Value = "" And Target.Offset(-1, 0) <> "" Then
        Application.EnableEvents = False
        Target.Offset(0, -1).Value = WorksheetFunction.CountA(Range("A:A"))
        Application.EnableEvents = True
    End If
End Sub
 
Upvote 0
:unsure: Sounds like you don't want the first column to sort when the table is sorted, nor do you want the first column to remain as it is when the table is sorted.

Could you use a prominent cell like B1 below to advise the use what number they should use next if creating a new row?

21 08 28.xlsm
AB
1Next Num: 6
2NumDate
343/03/2021
4531/05/2021
5225/07/2021
6314/08/2021
7115/08/2021
8
9
10
Table Index Number
Cell Formulas
RangeFormula
B1B1=MAX(Table3[Num])+1
 
Upvote 0

Forum statistics

Threads
1,214,790
Messages
6,121,607
Members
449,037
Latest member
Arbind kumar

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