il mio problema è che ho creato un userform di ricerca per un dato specifico nella colonna "N" e in automatico compila le test box relative ai campi di cui ho bisogno..solo che se ad esempio nella colonna N ho due dati uguali me ne trova uno solo..come posso fare o cosa devo aggiungere al codice sotto riportato per far si che mi esca un messaggio o qualche altra cosa che mi facciapresente che ci sono più dati associati a quel valore? oppure in alternativa un ulteriore texbox o una casella di controllo che mi dice che ci sono più dati collegati a quello della colonna N trovato...
ecco il codice confido nella vs. professionalità !! grazie in anticipo
- Codice: Seleziona tutto
Option Explicit
Private wk As Workbook
Private sh As Worksheet
Private Sub Frame1_Click()
End Sub
Private Sub Frame2_Click()
End Sub
Private Sub Label9_Click()
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub TextBox4_Change()
End Sub
Private Sub TextBox5_Change()
End Sub
Private Sub UserForm_Initialize()
Dim lUltRiga As Long
Dim lng As Long
Set wk = ThisWorkbook
With wk
Set sh = .Worksheets("Riepilogo")
End With
End Sub
Private Sub CommandButton1_Click()
Call mCerca(Me.TextBox1.Text)
End Sub
Private Sub mCerca(ByVal vValore As Variant)
Dim rng As Range
With sh
Set rng = _
.Range("n:n").Find( _
What:=vValore, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlRows, _
SearchDirection:=xlNext, _
MatchCase:=True)
End With
If rng Is Nothing Then
MsgBox "Nessun contratto Associato"
Me.TextBox2.Text = ""
Else
Me.TextBox2.Text = _
rng.Offset(0, -7).Value
End If
If rng Is Nothing Then
Me.TextBox3.Text = ""
Else
Me.TextBox3.Text = _
rng.Offset(0, -8).Value
End If
If rng Is Nothing Then
Me.TextBox4.Text = ""
Else
Me.TextBox4.Text = _
rng.Offset(0, -9).Value
End If
If rng Is Nothing Then
Me.TextBox5.Text = ""
Else
Me.TextBox5.Text = _
rng.Offset(0, 5).Value
End If
If rng Is Nothing Then
Me.TextBox6.Text = ""
Else
Me.TextBox6.Text = _
rng.Offset(0, 4).Value
End If
If rng Is Nothing Then
Me.TextBox7.Text = ""
Else
Me.TextBox7.Text = _
rng.Offset(0, -5).Value
End If
If rng Is Nothing Then
Me.TextBox8.Text = ""
Else
Me.TextBox8.Text = _
rng.Offset(0, -6).Value
End If
If rng Is Nothing Then
Me.TextBox9.Text = ""
Else
Me.TextBox9.Text = _
rng.Offset(0, -2).Value
End If
If rng Is Nothing Then
Me.TextBox10.Text = ""
Else
Me.TextBox10.Text = _
rng.Offset(0, -3).Value
End If
If rng Is Nothing Then
Me.TextBox11.Text = ""
Else
Me.TextBox11.Text = _
rng.Offset(0, 2).Value
End If
If rng Is Nothing Then
Me.TextBox12.Text = ""
Else
Me.TextBox12.Text = _
rng.Offset(0, -1).Value
End If
Set rng = Nothing
End Sub
Private Sub UserForm_Terminate()
Set sh = Nothing
Set wk = Nothing
End Sub
EDIT Flash ore 23:15 - Inserito l'intero codice nell'apposito Tag Code