Hilfe bei Suchfunktions button
#1
Hallo,

ich habe folgenden Code bei mir um eine Suchfunktion über ein Button zu starten, leider zeigt er mir nur die Zeilen an wo die betreffenden Suchwörter stehen,

ich möchte aber gerne das der Cursor in die Zeilen springt.

Bitte um Hilfe

DANKE

Sub Suchfunktion()

    Dim bFound As Boolean
    Dim rC As Range
    Dim tAddr As String
    Dim tSearch As String
    tSearch = InputBox("Suche nach:", "Suchen")
    If tSearch = "" Then Exit Sub
    With ActiveSheet.Cells
        Set rC = .Find(tSearch, LookIn:=xlValues)
        If Not rC Is Nothing Then
            tAddr = rC.Address
            Do
                MsgBox "Gefunden in " & rC.Address(0, 0) & ", Wert: " & rC.Value
                bFound = True
                Set rC = .FindNext(rC)
            Loop While Not rC Is Nothing And rC.Address <> tAddr
        End If
    End With
    If Not bFound Then MsgBox "Begriff [" & tSearch & "] nicht gefunden!"
End Sub
Top
#2
Hallo Andy,
Sub Suchfunktion()

   Dim bFound As Boolean
   Dim rC As Range
   Dim tAddr As String
   Dim tSearch As String
   tSearch = InputBox("Suche nach:", "Suchen")
   If tSearch = "" Then Exit Sub
   With ActiveSheet.Cells
       Set rC = .Find(tSearch, LookIn:=xlValues)
       If Not rC Is Nothing Then
           tAddr = rC.Address
           Do
               rC.Select
               MsgBox "Gefunden in " & rC.Address(0, 0) & ", Wert: " & rC.Value
               bFound = True
               Set rC = .FindNext(rC)
           Loop While Not rC Is Nothing And rC.Address <> tAddr
       End If
   End With
   If Not bFound Then MsgBox "Begriff [" & tSearch & "] nicht gefunden!"
End Sub
Gruß Uwe
Top
#3
Hallo Uwe,

Vielen DANK !

Gibt es noch die Möglichkeit die angezeigten Ergebnisse farbig zu hinterlegen ?

Vielen Dank
Top
#4
Hallo Andy,

(12.12.2016, 12:27)AndyExcel77 schrieb: Gibt es noch die Möglichkeit die angezeigten Ergebnisse farbig zu hinterlegen ?
Sub Suchfunktion()
   Dim bFound As Boolean
   Dim rC As Range
   Dim tAddr As String
   Dim tSearch As String
   tSearch = InputBox("Suche nach:", "Suchen")
   If tSearch = "" Then Exit Sub
   With ActiveSheet.Cells
       Set rC = .Find(tSearch, LookIn:=xlValues)
       If Not rC Is Nothing Then
           tAddr = rC.Address
           Do
               rC.Select
               rC.Interior.ColorIndex = 4
               MsgBox "Gefunden in " & rC.Address(0, 0) & ", Wert: " & rC.Value
               rC.Interior.ColorIndex = 0
               bFound = True
               Set rC = .FindNext(rC)
           Loop While Not rC Is Nothing And rC.Address <> tAddr
       End If
   End With
   If Not bFound Then MsgBox "Begriff [" & tSearch & "] nicht gefunden!"
End Sub
Gruß Uwe
Top
#5
(12.12.2016, 13:44)Kuwer schrieb: Hallo Andy,

Sub Suchfunktion()
   Dim bFound As Boolean
   Dim rC As Range
   Dim tAddr As String
   Dim tSearch As String
   tSearch = InputBox("Suche nach:", "Suchen")
   If tSearch = "" Then Exit Sub
   With ActiveSheet.Cells
       Set rC = .Find(tSearch, LookIn:=xlValues)
       If Not rC Is Nothing Then
           tAddr = rC.Address
           Do
               rC.Select
               rC.Interior.ColorIndex = 4
               MsgBox "Gefunden in " & rC.Address(0, 0) & ", Wert: " & rC.Value
               rC.Interior.ColorIndex = 0
               bFound = True
               Set rC = .FindNext(rC)
           Loop While Not rC Is Nothing And rC.Address <> tAddr
       End If
   End With
   If Not bFound Then MsgBox "Begriff [" & tSearch & "] nicht gefunden!"
End Sub
Gruß Uwe

Hallo,

Danke, leider zeigt er mir einen Fehler an und zwar in folgender Zeile

 rC.Interior.ColorIndex = 4


DANKE
Top
#6
(12.12.2016, 13:44) pid=\60865' schrieb:Undecided
Top
#7
(12.12.2016, 13:44)Kuwer schrieb: Hallo Andy,

Sub Suchfunktion()
   Dim bFound As Boolean
   Dim rC As Range
   Dim tAddr As String
   Dim tSearch As String
   tSearch = InputBox("Suche nach:", "Suchen")
   If tSearch = "" Then Exit Sub
   With ActiveSheet.Cells
       Set rC = .Find(tSearch, LookIn:=xlValues)
       If Not rC Is Nothing Then
           tAddr = rC.Address
           Do
               rC.Select
               rC.Interior.ColorIndex = 4
               MsgBox "Gefunden in " & rC.Address(0, 0) & ", Wert: " & rC.Value
               rC.Interior.ColorIndex = 0
               bFound = True
               Set rC = .FindNext(rC)
           Loop While Not rC Is Nothing And rC.Address <> tAddr
       End If
   End With
   If Not bFound Then MsgBox "Begriff [" & tSearch & "] nicht gefunden!"
End Sub
Gruß Uwe
DANKE hat doch Funktioniert

-CLOSED-
Top


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste