I agree with your method JapanDave for a None sorted list, their list gets sorted from time to time.
The one thing with the Change method, if an adjustment where to take place in an existing cell above.
The Counter will start placing new numbers at will, this could be a pro or con.
Yours with a twist.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr
Application.EnableEvents = 0
lr = Cells(Rows.Count, 1).End(xlUp).Row
If Not Intersect(Target, Range("B1:B" & lr + 1)) Is Nothing Then
'Added for sort method, just in case the number are not in order
ActiveWorkbook.Names.Add Name:="Complaints", RefersToR1C1:="=Sheet1!C1"
'Finds the Largest number in the list
ComplaintMax = Application.WorksheetFunction _
.Max(Range("Complaints"))
'Cells(lr + 1, 1).Value = Cells(lr, 1).Value + 1
'Takes the larges number and add 1 to it
Cells(lr + 1, 1).Value = ComplaintMax + 1
End If
Application.EnableEvents = 1
End Sub
Or
This method below also allows for this and fills in the next number in line by cell selection only (Active Cell).
Sub Macro5()
Dim ComplaintMax As Variant
'
' Macro5 Macro
''
'ActiveCell.FormulaR1C1 = "=R[-1]C+1"
ActiveWorkbook.Names.Add Name:="Complaints", RefersToR1C1:="=Sheet1!C1"
ComplaintMax = Application.WorksheetFunction _
.Max(Range("Complaints"))
'MsgBox ComplaintMax
ActiveCell.Cells = ComplaintMax + 1
End Sub
Bookmarks