search a workbook

  • Thread starter Thread starter Esau
  • Start date Start date
E

Esau

Is there a way to write this so it will search the
whole workbook at less 10 worksheets

Sub aaa()
'
WhatToFind = ActiveCell.Value
Cells.Find(What:=WhatToFind, After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
End Sub

I want to Thank You
Esau
 
Sub aaa()
'
Dim rng as Range, sh as Worksheet
WhatToFind = ActiveCell.Value
for each sh in Workbooks.Worksheets
sh.Activate
set rng = Cells.Find(What:=WhatToFind, _
After:=Range("IV65536"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
if not rng is nothing then
rng.Select
ans = msgbox( "continue searching? ", vbYesNo)
if ans = vbNo then exit sub
end if
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top