Thread: help
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.newusers
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default help

I used the example in the vba help index FINDNEXT and modified to suit.
Notice that there are NO selections, as they are NOT necessary or desirable.
This sub may be fired from anywhere in the workbook.

Sub findem()
what = InputBox("what to find ie:100")
For Each Ws In Worksheets
'MsgBox Ws.Name

With Ws.Range("a1:a500")
Set c = .Find(what, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
MsgBox what & " found at " & c.Address
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

Next Ws
End Sub

--
Don Guillett
SalesAid Software

"Monty" wrote in message
...
I have the following VBA working on my excel spreadsheet which works fine.
However what I would like to do is download my daily excel sheet in
relation
to cheques cashed by the bank and just add that worksheet to my workbook.
What happens then is it just searches the first worksheet and not the
second
or third one. So presently I have to copy and paste the info on to the
first
sheet in order for the VBA to work, Does anyone have any suggestions.


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