Hallo Helmut,
danke für deine Unterstützung. Jetzt hab ich es verstanden.
Der Code klappt nun wie vorgesehen.
Gruß
Johanna
Moderator: ModerationP
Sub KundenFinden()
Dim Suchzelle As String
Dim Kdno As String
Dim rngFound As Range
Dim firstAddress As Variant
Dim Frage As String
'Suchzelle = Worksheets("Kunden").Range("G3").Value
Frage = InputBox("Bitte geben Sie einen Wert ein", "Werte-Eingabe", , 200, 500)
MsgBox Frage
Suchzelle = Frage
With Worksheets("Kunden").Range("b2:b300")
Set rngFound = .Find(What:="*" & Suchzelle & "*", LookIn:=xlValues)
If Not rngFound Is Nothing Then
Do
firstAddress = rngFound.Address
Kdno = rngFound.Offset(, -1).Value
Set rngFound = .FindNext(rngFound)
MsgBox Kdno
Loop While rngFound.Address <> firstAddress
MsgBox "Suche abgeschlossen."
Else
MsgBox "Suche war ergebnislos."
End If
End With
End Sub
Option Explicit
Sub KundenFinden2()
Dim Suchzelle As String
Dim Kdno As String
Dim rngFound As Range
Dim firstAddress As Variant
Dim Frage As String
Dim Name As String
'Suchzelle = Worksheets("Kunden").Range("G3").Value
Frage = InputBox("Bitte geben Sie einen Wert ein", "Werte-Eingabe", , 200, 500)
MsgBox Frage
Suchzelle = Frage
With Worksheets("Kunden").Range("b2:b300")
Set rngFound = .Find(What:="*" & Suchzelle & "*", LookIn:=xlValues)
'MsgBox rngFound.Address
If Not rngFound Is Nothing Then
firstAddress = rngFound.Address
Do
Name = rngFound
MsgBox Name
Kdno = rngFound.Offset(, -1).Value
Set rngFound = .FindNext(rngFound)
MsgBox Kdno
Loop While rngFound.Address <> firstAddress
MsgBox "Suche abgeschlossen."
Else
MsgBox "Suche war ergebnislos."
End If
End With
End Sub
Zurück zu Excel Forum (provisorisch)
Mitglieder in diesem Forum: 0 Mitglieder und 17 Gäste