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
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
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:1 Nutzer sagt Danke an Gast für diesen Beitrag 28 • Rudi'S
19.07.2020, 13:39 (Dieser Beitrag wurde zuletzt bearbeitet: 19.07.2020, 13:40 von snb.)
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