Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1140to1144
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Wort suchen abbrechen

Wort suchen abbrechen
Hannes
Hallo,
ich habe hier ein Macro mit dem ich ein Wort in allen Exceltabellen suchen kann.
Ein paar Erweiterungen hätte ich hierzu gerne:
1. Suche abbrechen
2. nach Beenden der Suche oder Abbruch wieder auf der ersten Seite starten
Leider habe ich keine VBA Kenntnisse, aber vielleicht könnt ihr mir ja weiterhelfen.
Sub FindItAll()
Dim oSheet As Object
Dim Firstcell As Range
Dim NextCell As Range
Dim WhatToFind As Variant
WhatToFind = Application.InputBox("What are you looking for ?", "Search", , 100, 100, , , 2) _
If WhatToFind  "" And Not WhatToFind = False Then
For Each oSheet In ActiveWorkbook.Worksheets
oSheet.Activate
oSheet.[a1].Activate
Set Firstcell = Cells.Find(What:=WhatToFind, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not Firstcell Is Nothing Then
Firstcell.Activate
MsgBox ("Found " & Chr(34) & WhatToFind & Chr(34) & " in " & oSheet.Name & "!" & _
Firstcell.Address)
On Error Resume Next
While (Not NextCell Is Nothing) And (Not NextCell.Address = Firstcell. _
Address)
Set NextCell = Cells.FindNext(After:=ActiveCell)
If Not NextCell.Address = Firstcell.Address Then
NextCell.Activate
MsgBox ("Found " & Chr(34) & WhatToFind & Chr(34) & " in " & oSheet. _
Name & "!" & NextCell.Address)
End If
Wend
End If
Set NextCell = Nothing
Set Firstcell = Nothing
Next oSheet
End If
End Sub
Vielen Dank!
Gruß Hannes

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Wort suchen abbrechen
04.03.2010 16:26:07
fcs
Hallo Hannes,
ich hab die MsgBoxen so angepasst, dass du auch abbrechen kannst, und entsprechende If-Abfragen eingebaut.
Gruß
Franz
Sub FindItAll()
Dim oSheet As Object, oStart As Object
Dim Firstcell As Range
Dim NextCell As Range
Dim WhatToFind As Variant
Set oStart = ActiveSheet 'oder = Sheets(1)
WhatToFind = Application.InputBox("What are you looking for ?", _
"Search", , 100, 100, , , 2)
If WhatToFind  "" And Not WhatToFind = False Then
For Each oSheet In ActiveWorkbook.Worksheets
oSheet.Activate
oSheet.[a1].Activate
Set Firstcell = Cells.Find(What:=WhatToFind, LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not Firstcell Is Nothing Then
Firstcell.Activate
If MsgBox("Found " & Chr(34) & WhatToFind & Chr(34) & " in " & oSheet.Name & "!"  _
_
& Firstcell.Address, vbInformation + vbRetryCancel, "Suchen in Mappe") _
= vbRetry Then
On Error Resume Next
While (Not NextCell Is Nothing) And (Not NextCell.Address = _
Firstcell.Address)
Set NextCell = Cells.FindNext(After:=ActiveCell)
If Not NextCell.Address = Firstcell.Address Then
NextCell.Activate
If MsgBox("Found " & Chr(34) & WhatToFind & Chr(34) & " in " _
& oSheet.Name & "!" & NextCell.Address, _
vbInformation + vbRetryCancel, "Suchen in Mappe") _
= vbCancel Then Exit For
End If
Wend
End If
End If
Set NextCell = Nothing
Set Firstcell = Nothing
Next oSheet
End If
oStart.Activate
End Sub

Anzeige
AW: Wort suchen abbrechen
05.03.2010 08:25:23
Hannes
Danke Franz,
klappt super!

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige