Private Sub Worksheet_Selectionchange(ByVal Target As Range)
A = "A" 'عمود التسلسل
B = "B" 'عمود البيانات
R = 3 'البيانات تبدأ من الصف
'=================================================
L = Range(B & 65000).End(xlUp).Row
If L < R Then Exit Sub
Range(Cells(R, A), Cells(L, A)).ClearContents
'=================================================
For i = R To L
If Cells(i, A) = "" And Cells(i, B) <> "" Then
N = N + 1
For ii = i To L
If Cells(ii, B) = Cells(i, B) Then
Cells(ii, A) = N
End If
Next ii
End If
Next i
End Sub
===============================================
أحى الفاضل / إبراهيم ابوليله
ضع هذا الكود فى حدث الورقة المختارة
يعمل بدون زر