Anzeige
Archiv - Navigation
1508to1512
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

FindNext

FindNext
29.08.2016 15:32:18
Eisert
Hallo Leute,
weiß jemand wie ich bei dem unten stehenden Code "FindNext" richtig einsetzten muss?
Ich will das nach "If Tabelle2.Cells(6, 1) = c Then" falls es zu keiner Übereinstimmung gekommen ist, weiter gesucht wird, bis alle Werte in der Spalte durchsucht sind. Irgendwie bekomme ich das nicht hin. Danke euch schon mal...
MfG Eisert
Private Sub CommandButton1_Click()
For i = 5 To 34
a = Tabelle2.Cells(5, i)
If Tabelle2.Cells(8, 1) = "Start" Then
Set b = Tabelle3.Range("D:D").Find(a, LookIn:=xlValues)
If b Is Nothing Then GoTo n1
c = b.Offset(0, -3)
If Tabelle2.Cells(6, 1) = c Then
Tabelle2.Cells(6, i) = b.Offset(0, 2)
End If
Else
Set b = Tabelle3.Range("E:E").Find(a, LookIn:=xlValues)
If b Is Nothing Then GoTo n1
c = b.Offset(0, -4)
If Tabelle2.Cells(6, 1) = c Then
Tabelle2.Cells(6, i) = b.Offset(0, 1)
End If
n1:
End If
Next i
End Sub

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: FindNext
30.08.2016 01:32:23
fcs
Hallo Eisert,
nachfolgend dein Makro angepasst, wie es prinzipiell aussehen kann.
Den jeweils zu durchsuchenden Zellbereich must du noch festlegen, ebenso ggf. was gesucht werden soll und welches Ergebnis wo eingetragen werden soll.
Gruß
Franz
Private Sub CommandButton1_Click()
Dim i, a, b As Range, c
Dim rngBereich As Range, rngFind As Range, str1stAdress As String
For i = 5 To 34
a = Tabelle2.Cells(5, i)
If Tabelle2.Cells(8, 1) = "Start" Then
Set b = Tabelle3.Range("D:D").Find(a, LookIn:=xlValues)
If b Is Nothing Then GoTo n1
c = b.Offset(0, -3)
If Tabelle2.Cells(6, 1) = c Then
Tabelle2.Cells(6, i) = b.Offset(0, 2)
Else
With Tabelle2
Set rngBereich = .Range(.Cells(7, i), .Cells(.Rows.Count, i).End(xlUp))
End With
Set rngFind = rngBereich.Find(what:=c, LookIn:=xlValues, lookat:=xlWhole)
If Not rngFind Is Nothing Then
str1stAdress = rngFind.Address
Do
rngFind.Value = b.Offset(0, 2)
Set rngFind = rngBereich.FindNext(after:=rngFind)
Loop Until rngFind.Address = str1stAdress
End If
End If
Else
Set b = Tabelle3.Range("E:E").Find(a, LookIn:=xlValues)
If b Is Nothing Then GoTo n1
c = b.Offset(0, -4)
If Tabelle2.Cells(6, 1) = c Then
Tabelle2.Cells(6, i) = b.Offset(0, 1)
Else
With Tabelle2
Set rngBereich = .Range(.Cells(7, i), .Cells(.Rows.Count, i).End(xlUp))
End With
Set rngFind = rngBereich.Find(what:=c, LookIn:=xlValues, lookat:=xlWhole)
If Not rngFind Is Nothing Then
str1stAdress = rngFind.Address
Do
rngFind.Value = b.Offset(0, 1)
Set rngFind = rngBereich.FindNext(after:=rngFind)
Loop Until rngFind.Address = str1stAdress
End If
End If
n1:
End If
Next i
End Sub

Anzeige
AW: FindNext
30.08.2016 11:02:19
Eisert
Danke dir Franz... hab es angepasst und es läuft super...

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige