"Gianni" <
palg...@libero.it> ha scritto nel messaggio
news:31161755.586.1328787841915.JavaMail.geo-discussion-forums@yqcr15...
***************************
La tua sub numera progressivamente i dati inseriti in colonna B, secondo
l'ordine di immissione.
Cosa dovrebbe succedere se dopo aver inserito 10 dati cancello il terzo
inserito?
Che quello che prima risultava 4° appaia ora come 3° e così via per gli
altri successivi?
Se è così, prova in questo modo:
-------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng1 As Range
Dim Rng2 As Range
Dim c1 As Range, c2 As Range
Dim iVal As Long
Set Rng1 = Columns("B:B")
Set Rng2 = Intersect(Rng1, Target)
If Not Rng2 Is Nothing Then
iVal = Application.Max(Rng1.Offset(0, -1))
On Error GoTo XIT
Application.EnableEvents = False
For Each c1 In Rng2.Cells
With c1
If Not IsEmpty(.Value) Then
With .Offset(0, -1)
If IsEmpty(.Value) Then
iVal = iVal + 1
.Value = iVal
.NumberFormat = "0"
End If
End With
Else
With .Offset(0, -1)
If Not IsEmpty(.Value) Then
iVal = .Value
.Value = ""
For Each c2 In Rng1.Offset(0, -1).Cells
If c2 > iVal Then c2 = c2 - 1
Next c2
End If
End With
End If
End With
Next c1
End If
XIT:
Application.EnableEvents = True
End Sub
--------------------
Ciao,
E.