OzGrid

How to search for a word inside a workbook and open that sheet as active sheet

< Back to Search results

 Category: [Excel]  Demo Available 

How to search for a word inside a workbook and open that sheet as active sheet

 

Requirement:

 

The user wants to search a word inside a workbook and open that sheet as active sheet.

 

Solution:

 

Code:
Sub ActivateSheet()
    Application.ScreenUpdating = False
    Dim ws As Worksheet, fnd As Range, response As String
    response = InputBox("Enter the word to search.")
    If response = "" Then Exit Sub
    For Each ws In Sheets
        Set fnd = ws.UsedRange.Find(response, LookIn:=xlValues, lookat:=xlPart)
        If Not fnd Is Nothing Then
            ws.Activate
            Exit For
        End If
    Next ws
    Application.ScreenUpdating = True
End Sub

 

Obtained from the OzGrid Help Forum.

Solution provided by Mumps.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

How to compare two workbooks with multiple sheets and highlighting duplicates
How to use a macro to copy data from multiple workbooks to one master sheet in another workbook
How to copy data from multiple workbooks into one
How to set cell as the name of the other open workbook
How to copy data in VBA from different named workbook each time

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)