
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rFound As Excel.Range
If Target.Column = 2 And Target.Value <> "" Then
NewVal = Target.Value
Set rFound = Range("B:B").Find(What:=NewVal, MatchCase:=False, Lookat:=xlWhole)
If Not rFound Is Nothing Then
MsgBox ("Codice già inserito in riga " & rFound.Row)
End If
End If
End Sub |
Sub codici_doppi()
With Worksheets(1).Range("b1:b65000")
valore = ActiveCell.Value
If valore = "" Then Exit Sub
Set c = .Find(valore, LookIn:=xlValues)
If Not c Is Nothing Then
primoIndirizzo = c.Address
Do
c.Interior.Pattern = xlPatternGray50
flag = 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> primoIndirizzo
If flag = 1 Then MsgBox ("Codice Inserito")
End If
End With
End Sub |
Sub ControlloDati_mod()
Dim Valore As String
Dim Elenco As Range
Dim d As Range
Valore = ActiveCell.Value
If Valore = " - " Then Exit Sub
Set Elenco = Range("D3:D65000")
For Each d In Elenco
If d.Address = ActiveCell.Address Then Exit Sub
If d.Value = Valore Then
MsgBox "Il valore " & d.Value & " è presente nella cella " & d.Address
End If
Next d
End Sub |
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rFound As Excel.Range
If Target.Column = 3 And Target.Value <> "" Then
NewVal = Target.Value
Set rFound = Range("C:C").Find(What:=NewVal, MatchCase:=False, Lookat:=xlWhole)
If Not rFound Is Nothing Then
MsgBox ("Codice già inserito in riga " & rFound.Row)
End If
End If
End Sub |
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 And Target.Value <> "" Then
NewVal = Target.Value
For r = Target.Row - 1 To 3 Step -1
If Cells(r, 2) = NewVal Then
MsgBox ("Codice già inserito in riga " & r)
Exit For
End If
Next
End If
End Sub |
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub '<<<<<<<<<<<
If Target.Column = 2 And Target.Value <> "" Then
NewVal = Target.Value
For r = Target.Row - 1 To 3 Step -1
If Cells(r, 2) = NewVal Then
MsgBox ("Codice già inserito in riga " & r)
Exit For
End If
Next
End If
|
