Supportnet Computer
Planet of Tech

Supportnet / Forum / Tabellenkalkulation

Suchmaske verändern





Frage

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 1 von rainberg

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

Hallo Rainer,
funktioniert super.

Danke!!

Gruß
fedjo

Ich möchte kostenlos eine Frage an die Mitglieder stellen:


Ähnliche Themen:


Suche in allen vorhandenen Beiträgen: