Suche in einem Worksheet
Erich
habe mit Hilfe des Forums eine UserForm mit einem Code erstellt, der mir
in allen Tabellen ein Wort sucht. Nun scheitere ich daran, dass die Suche
nur in einem Worksheet (mit ComboBox definiert als: myName1) erfolgt.
Hier mein derzeitiger Code (leider funktioniert meine Jeanie nicht richtig?):
Sub Muster() <a href="'https://www.herber.de/forum/archiv/224to228/t225904.htm">'https://www.herber.de/forum/archiv/224to228/t225904.htm</a>
'Re: suchen und kopieren ' mehrmals geändert Erich M. sFind = myWert1 ' = Auswahl in ComboBox oder über: InputBox("Bitte Suchbegriff eingeben:") If sFind = "" Then Exit Sub mySpalte = mySpalte '= Auswahl in ComboBox oder über: InputBox("Bitte Spalte eingeben:") 'If mySpalte = "" Then Exit Sub tarWks = "Gefunden" ' Zieltabelle Cr = 65536 If Worksheets(tarWks).Cells(Cr, 1) = "" Then Cr = Worksheets(tarWks).Cells(Cr, 1).End(xlUp).Row End If If Cr = 2 Then Cr = 3 For Each wks In Worksheets 'nur Suche in einer Tabelle in mySpalte; Tabelle = myName1 (Auswahl per ComboBox) If wks.Name = tarWks Then GoTo Exitfor Set rng = wks(myName1).Columns(mySpalte).Find(what:=sFind, _ lookat:=xlWhole, LookIn:=xlValue) 'xlFormulas If Not rng Is Nothing Then sAddress = rng.Address Do Application.Goto rng, True ' If MsgBox("Weiter und kopieren", vbYesNo + vbQuestion) = vbNo Then Exit Sub wks.Rows(rng.Row).Copy Destination:=Worksheets(tarWks).Rows(Cr) wks.Rows(rng.Row).Copy 'neu Worksheets(tarWks).Rows(Cr).PasteSpecial Paste:=xlValues, _ Operation:=xlNone, SkipBlanks:=False, Transpose:=False 'neu Application.CutCopyMode = False 'neu Cr = Cr + 1 Set rng = Columns(mySpalte).Cells.FindNext(after:=ActiveCell) If rng.Address = sAddress Then Exit Do Loop End If Exitfor: Next wks End Sub
Besten Dank für eine Hilfe!
mfg
Erich