online 1
gast (50)

/ Forum / Tabellenkalkulation

TabellenkalkulationTabellenkalkulation

Fragevon fedjo vom 17.12.2019, 19:33 Options

Suchmaske verändern

Hallo Excelfreunde,
wenn die Suchmaske kein Ergebnis findet soll ein Hinweis ausgegeben werden.
Wo und wie muß ich den Code verändern?

Ich hoffe Ihr habt eine Idee dazu.

Gruß
fedjo

Sub Suchen()
Dim lngI As Long, strSuch As String, lngAnz As Long
On Error Resume Next
strSuch = InputBox("Suchen nach:", "Suchen in Spalte: C")
If strSuch = "" Then
Exit Sub
End If
lngAnz = WorksheetFunction.CountIf(Range("C4:C60000"), strSuch)
Range("C4:C60000").Find(what:=strSuch, LookIn:=xlValues, MatchCase:=False).Activate
For lngI = 1 To lngAnz - 1
If MsgBox("Weitersuchen ?", vbQuestion + vbYesNo) = vbYes Then
Range("C4:C60000").FindNext(After:=ActiveCell).Activate

End If
Next
End Sub


Antwort schreiben

Antwort 1 von rainberg vom 17.12.2019, 22:59 Options

Hallo fedjo,

anbei die Änderung

Option Explicit

Sub suchen2()
    Dim c, firstAddress
    Dim strSuch As String, rngBer As Range
    Set rngBer = Range("C4:C" & Range("C65536").End(xlUp).Row)
    With rngBer
        .Interior.ColorIndex = xlNone
        strSuch = InputBox("Suchen nach:", "Suchen in Spalte: C")
        Set c = .Find(strSuch, LookIn:=xlValues)
        If c Is Nothing Then
            MsgBox "Eintrag nicht vorhanden"
            Exit Sub
        Else
            firstAddress = c.Address
            Do
                c.Interior.ColorIndex = 3
                If MsgBox("Weitersuchen ?", vbQuestion + vbYesNo) = vbYes Then
                    Set c = .FindNext(c)
                Else
                    Exit Sub
                End If
            Loop While Not c Is Nothing And c.Address <> firstAddress
        End If
   End With
End Sub


Gruß
Rainer

Antwort 2 von fedjo vom 18.12.2019, 16:25 Options

Hallo Rainer,
funktioniert super.

Danke!!

Gruß
fedjo

Ähnliche Themen

DISPLAY.SYS verändern und bearbieten
nixwisser  09.02.2007 - 60 Hits - 4 Antworten

Datensatz suchen, Suchmaske
HolySteiger  19.07.2007 - 157 Hits -

sich aufklappende suchmaske bei google etc.
Samari  23.10.2007 - 62 Hits - 2 Antworten

Zellinhalte verändern
4r4n  28.03.2008 - 58 Hits - 2 Antworten

Hinweis

Diese Frage ist schon etwas älter, Sie können daher nicht mehr auf sie antworten. Sollte Ihre Frage noch nicht gelöst sein, stellen Sie einfach eine neue Frage im Forum..

Neue Einträge

Version: supportware 1.9.150 / 10.06.2022, Startzeit:Thu Jan 8 21:07:44 2026