For i = 3 To Cells(Rows.Count, 4).End(xlUp).Row
If Cells(i, 4) <> "" Then Cells(i, 2) = i - 2
Next
x = 1
For i = 3 To Cells(Rows.Count, 4).End(xlUp).Row
If Cells(i, 4) <> "" Then Cells(i, 2) = x: x = x + 1
Next
=SI(D3="";"";MAX(B$2:B2)+1)
Private Sub Worksheet_Change(ByVal Target As Range)
With [B3:B200]
If Not Intersect(Target, .Resize(, 3)) Is Nothing Then 'colonnes B:D
Application.EnableEvents = False
.FormulaR1C1 = "=IF(RC4="""","""",MAX(R2C:R[-1]C)+1)"
.Value = .Value
Application.EnableEvents = True
End If
End With
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Selection.Columns.Count > 1 Then Exit Sub
Application.EnableEvents = False
For Each cel In Range("D3:D" & Rows.Count).SpecialCells(xlCellTypeConstants)
If cel.Offset(0, -2) = "" Then cel.Offset(0, -2) = cel.Offset(-1, -2) + 1
Next
Application.EnableEvents = True
End Sub