Ich habe eine Userform (Combobox1 und Commandbutton1)mit welcher ich einen bestimmten Namen in der ganzen Arbeitsmappe suchen kann. In der Combobox1 gebe ich den Suchbegriff ein und mit Commandbutton1 löse ich die Suchfunktion aus. Ich möchte in die Userform eine Textbox einbauen welche mir auch die Nachbarzelle der Fundstelle anzeigt. Ich probiere das schon den ganzen Tag z.B.:TextBox1 = Cells(Combobox1.ListIndex + 1, 2). Ich bin scheinbar zu blöd. Vielleicht kann mir wer helfen.
Private Sub CommandButton1_Click()
Dim wks As Worksheet
Dim rng As Range
Dim sAddress As String, sFind As String
sFind = ComboBox1 & "*" ' plus Sterchen
If sFind = "" Then Exit Sub
For Each wks In Worksheets
Set rng = wks.Cells.Find(what:=sFind, _
lookat:=xlWhole, LookIn:=xlValues)
If Not rng Is Nothing Then
sAddress = rng.Address
Do
Application.Goto rng, True
Application.Goto Reference:=Range("A1"), Scroll:=True
Range(rng.Address).Select
If MsgBox("Soll die Suche fortgesetzt werden ?", _
vbYesNo + vbQuestion, "Frage an " & _
Application.UserName & ":") = vbNo Then Exit Sub
Set rng = Cells.FindNext(after:=ActiveCell)
If rng.Address = sAddress Then Exit Do
Loop
End If
Next wks
MsgBox "Es gibt keine neue Fundstelle !", vbYes + vbInformation, _
"Dezenter Hinweis für " & Application.UserName & ":"
End Sub
Danke für eure Hilfe
Michael