ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search all worksheets (https://www.excelbanter.com/excel-programming/397362-search-all-worksheets.html)

[email protected]

Search all worksheets
 
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?


Jim Thomlinson

Search all worksheets
 
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
--
HTH...

Jim Thomlinson


" wrote:

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?




All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com