Suche den (Teil)String
#1
Hallo,
Ich versuche mit dem Code, eine TextSuche wiederholen, solange User nicht Cancel anklickt bzw. einen Teil des Textes gefunden würde, Klein& Großschreibung ist egal.

Ich bekomme Error: typen unverträglich


danke für Hilfe





Sub SearchIn()
  Dim myString As Variant
  Dim found1 As Range
   
    Do
    myString = Application.InputBox(Prompt:="Search for ...", Title:="Enter the search text here", Default:=" ")
    If found1 Is Nothing Then
        MsgBox "Your search did not return any results. The searched-on text was:" & vbCrLf & vbCrLf & myString & vbCrLf & vbCrLf & "Try to modify your search to find results containing the Phrase search!"
    Else
        Cells.Find(myString, LookAt:=xlPart).Activate
    End If
   
    Loop Until myString
       
End Sub
Top
#2
Hallo, :19:

probiere es mal so: :21:

Code:
Option Explicit
Public Sub Main()
    Dim strAdress As String
    Dim rngRange As Range
    Dim strTMP As String
    With ThisWorkbook.Worksheets("Tabelle1")
        strTMP = Application.InputBox(Prompt:="Search for ...", Title:="Enter the search text here", Default:="D_2")
        Set rngRange = .Cells.Find(strTMP, After:=.Range("D1"), LookAt:=xlPart, LookIn:=xlValues)
        If Not rngRange Is Nothing Then
            strAdress = rngRange.Address
            Do
                Select Case MsgBox("Weitersuchen ""Ja"" - Abbrechen ""Nein"".", vbYesNo Or vbQuestion, "Gefunden in: " & rngRange.Address)
                    Case vbYes
                        Set rngRange = .Cells.FindNext(rngRange)
                    Case vbNo
                        Exit Do
                End Select
            Loop While rngRange.Address <> strAdress
        Else
            MsgBox "Nichts gefunden!"
        End If
    End With
End Sub
Top
#3
Danke Case für Hilfe,

ist es möglich?

1-Wenn ich nach "guardian"(ohne") suchen würde, sagt das Macro, nichts gefunden!, hier sollte das inputbox wieder kommen:

strTMP = Application.InputBox(Prompt:="Search for ...", Title:="Enter the search text here", Default:="D_2")

Der User hat die Möglichkeit weiter zu suchen, indem er etwas Neues eingibt oder abbrechen.



2-Wenn ich nach „daily“ suchen würde, findet das Macro das Word und sollte auf Celle springen.


Besten Dank
Top
#4
Hallo, :19:

kaum getestet: :21:

Code:
Option Explicit
Public Sub Main()
    Dim strAdress1 As String
    Dim strAdress2 As String
    Dim rngRange1 As Range
    Dim rngRange2 As Range
    Dim strTMP As String
    With ThisWorkbook.Worksheets("Tabelle1")
        strTMP = Application.InputBox(Prompt:="Search for ...", Title:="Enter the search text here", Default:="D_2")
        Set rngRange1 = .Cells.Find(strTMP, After:=.Range("A1"), LookAt:=xlPart, LookIn:=xlValues)
        If Not rngRange1 Is Nothing Then
            strAdress1 = rngRange1.Address
            Application.Goto rngRange1, False
            Do
                Select Case MsgBox("Weiter ""Ja"" - Neue Suche ""Nein"" - oder Ende ""Abbrechen"".", vbYesNoCancel Or vbQuestion, "Gefunden in: " & rngRange1.Address)
                    Case vbYes
                        Application.Goto rngRange1, False
                        Set rngRange2 = .Cells.Find(strTMP, After:=rngRange1, LookAt:=xlPart, LookIn:=xlValues)
                        If Not rngRange2 Is Nothing Then
                            strAdress2 = rngRange2.Address
                            Application.Goto rngRange2, False
                            Do
                                Select Case MsgBox("Weiter ""Ja"" - Abrechen ""Nein"".", vbYesNo Or vbQuestion, "Gefunden in: " & rngRange2.Address)
                                    Case vbYes
                                        Set rngRange2 = .Cells.FindNext(rngRange2)
                                        Application.Goto rngRange2, False
                                    Case vbNo
                                        Exit Do
                                End Select
                            Loop While rngRange2.Address <> strAdress2
                        End If
                    Case vbNo
                        Call Main
                    Case vbCancel
                        Exit Sub
                End Select
            Loop While rngRange1.Address <> strAdress1
        Else
            Select Case MsgBox("Neue Suche ""Ja"" - Abrechen ""Nein"".", vbYesNo Or vbQuestion, "Nichts gefunden...")
                Case vbYes
                    Call Main
                Case vbNo
                    Exit Sub
            End Select
        End If
    End With
End Sub
[-] Folgende(r) 1 Nutzer sagt Danke an Gast für diesen Beitrag:
  • Rudi'S
Top
#5
Oder

Code:
Sub M_snb()
  sn = ActiveSheet.UsedRange
   
  c00 = InputBox("", "search")
   
  For j = 1 To UBound(sn)
    For jj = 1 To UBound(sn, 2)
      If instr(sn(j, jj), c00) Then
        Application.Goto Cells(j, jj)
        If MsgBox("", vbYesNo, "Continue ?") = vbNo Then Exit Sub
      End If
    Next
  Next
End Sub
Zum übersetzen von Excel Formeln:

http://dolf.trieschnigg.nl/excel/index.p...gids=en+de
Top
#6
In der Datei implementiertL


Angehängte Dateien
.xlsb   __suche.xlsb (Größe: 20,86 KB / Downloads: 2)
Zum übersetzen von Excel Formeln:

http://dolf.trieschnigg.nl/excel/index.p...gids=en+de
Top


Gehe zu:


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