Search all worksheets

  • Thread starter Thread starter jneaves
  • Start date Start date
J

jneaves

Hey, I have a workbook with many worksheets. I am trying to write a
macro to search all the worksheets for a unique value. I have a
userform to enter the value and assign it to a variable. I just need
to search all sheet for that string, and if that string exists in a
worksheet, activate that worksheet. Anyone done anything like this?
Can you help?
 
This should be close...

Sub FindStuff()
Dim wks As Worksheet
Dim rngFound As Range

For Each wks In Worksheets
Set rngFound = wks.Cells.Find(What:="asdf", _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
MatchCase:=False)
If Not rngFound Is Nothing Then
wks.Select
rngFound.Select
Exit For
End If
Next wks
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