afficher résultat dans textbox
bonjour le forum !
Je fais une recherche et les résultats sont affiché dans une autre feuille.
J'aimerais savoir comment il serait possible d'afficher le résultat dans un textbox du userform ? (Car le recherche se lance à partir d'un textbox)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Private Sub CommandButton1_Click()
Dim FoundCount As Double
Dim rFoundB As Range, rFoundC As Range
Dim rFoundD As Range, MyTextB As String
Dim MyTextC As String, MyTextD As String
Dim B As Range, C As Range, D As Range
Dim rB As Range, rC As Range, rD As Range
MyTextB = Me.txtfindB.Value
txtresult.MultiLine = True
Sheets("Sheet2").Range("A2:f65536").ClearContents
If Trim(MyTextB) <> "*" Then
With Worksheets("BT")
Set rB = .Range("b1:b65536")
End With
Set rFoundB = rB.Resize(1, 1)
Set B = rB.Find(MyTextB, After:=rFoundB, _
LookIn:=xlValues, _
Lookat:=xlPart)
If Not B Is Nothing Then
firstAddress = B.Address
Do
bcopy = False
If (InStr(1, B.Offset(0, 1), Trim(MyTextC), vbTextCompare) > 0 _
Or Trim(MyTextC) = "*" _
Or Len(Trim(MyTextC)) = 0) And _
(InStr(1, B.Offset(0, 2), Trim(MyTextD), vbTextCompare) > 0 _
Or Trim(MyTextD) = "*" Or Len(Trim(MyTextD)) = 0) Then
lr = Sheets("Sheet2").Cells(Rows.Count, "a").End(xlUp).Row + 1
B.EntireRow.Copy Sheets("Sheet2").Rows(lr)
FoundCount = FoundCount + 1
End If
Set B = rB.FindNext(B)
Loop While Not B Is Nothing And B.Address <> firstAddress
End If ' not B is Nothing
End If
MsgBox FoundCount & " valeurs trouvés", vbInformation, "Transfert complété"
'Sheets("Sheet2").Select
End Sub |
merci encore une fois tout le monde !