ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search Mutiple Excel Sheets. (https://www.excelbanter.com/excel-programming/273960-search-mutiple-excel-sheets.html)

Ben Jimenez

Search Mutiple Excel Sheets.
 
Hello,

This is just a follow up to those that helped me figure
out how to search mutiple sheets. Here is the code i used,
i made some small modifications to it. I did not want to
search the first two sheets of my workbook so i added a
little counter to skip these two. Thanks again for those
who helped me out.

Ben

Dim sh As Worksheet
Dim rng As Range
Dim sTarget As String
Dim sCnt As Integer


sTarget = TextBox1.Text
For Each sh In ThisWorkbook.Worksheets
If sCnt 1 Then
Set rng = Nothing
Set rng = sh.Cells.Find(sTarget)

If Not rng Is Nothing Then
sh.Activate
rng.Select
Exit Sub
End If
End If
sCnt = sCnt + 1
Next

MsgBox "The search data was not found."


All times are GMT +1. The time now is 11:26 AM.

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