Hi, I'm new to VBA and would hope to get some help here.
At column D, I have sorted all "B" follow by "P".
I have the undermentioned code to list the S/N for column A from 1 onwards.
But I would need the S/N to start from one again once the Column D value is "P".
Your assistance is very much appreciated.
Seems like I can't upload a picture so appreciate your help with above wordings.
Thanx.
Dim k As Integer
Dim LR As Integer
'Find the last row with data
LR = Range("D" & Rows.Count).End(xlUp).Row
For k = LR To 2 Step -1
If Cells(k, 4).Value = "B" Then
Cells(k, 1).Value = k - 1
ElseIf Cells(k, 4).Value = "P" Then
Cells(k, 1).Value = k - 2
End If
Next k
At column D, I have sorted all "B" follow by "P".
I have the undermentioned code to list the S/N for column A from 1 onwards.
But I would need the S/N to start from one again once the Column D value is "P".
Your assistance is very much appreciated.
Seems like I can't upload a picture so appreciate your help with above wordings.
Thanx.
Dim k As Integer
Dim LR As Integer
'Find the last row with data
LR = Range("D" & Rows.Count).End(xlUp).Row
For k = LR To 2 Step -1
If Cells(k, 4).Value = "B" Then
Cells(k, 1).Value = k - 1
ElseIf Cells(k, 4).Value = "P" Then
Cells(k, 1).Value = k - 2
End If
Next k