Search for worksheet name in Excel spreadsheet

  • Thread starter Thread starter SANTANDER
  • Start date Start date
S

SANTANDER

I am trying to find the best way to search for a particular worksheet name
in the spreadsheet that has many worksheets in the file (search in opened
spreadsheet). Search result need move me in to appropriate worksheet. Some
worksheet in that workbook may have the same name, marked with 1, 2, 3..
like Name-1, Name-2, Name-3.. or Name1, Name2, etc
I appreciate any help and code samples.

Regards,
S.
 
Try something like this:

Dim myWB As Workbook
Dim myWS As Worksheet

Set myWS = Nothing
On Error Resume Next
Set myWS = Worksheets("Name-1")
On Error GoTo 0
If Not myWS Is Nothing Then
MsgBox ("You've found your worksheet.")
Else
MsgBox ("You haven't found your worksheet")
End If
 
I am trying to find the best way to search for a particular worksheet name
in the spreadsheet that has many worksheets in the file (search in opened
spreadsheet). Search result need move me in to appropriate worksheet. Some
worksheet in that workbook may have the same name, marked with 1, 2, 3..
like Name-1, Name-2, Name-3.. or Name1, Name2, etc
I appreciate any help and code samples.

Regards,
S.

Hi
Activeworkbook.Worksheets("Name1").Activate

will activate the sheet called "Name1"

If the workbook is open but not necessarily active then
Workbooks("Myworkbook).Worksheets("Name1").Activate

will do it.

It would be easy to populate a drop down menu with worksheet names for
users to pick from, if that is what you want?
regards
Paul
 
If the workbook is open but not necessarily active then
Workbooks("Myworkbook).Worksheets("Name1").Activate
will do it.
It would be easy to populate a drop down menu with worksheet names for
users to pick from, if that is what you want?
regards
Paul
-------------

Yes, populating a drop down menu with worksheet names for users to pick
from(when this required only, not constantly) may be an option.
How should look this code and where it goes - inside Module1? Does this code
will count newly added worksheet also?

Regards,
Santander
 
Sub FindSheet()
Dim i As Integer
Name = InputBox("Please Enter the Name of the Worksheet to Find",
"SheetSearch", vbOKOnly)
For i = 1 To Worksheets.Count
If Application.ActiveWorkbook.Sheets(i).Name = Name Then
Application.ActiveWorkbook.Sheets(i).Select
End If
Next
End Sub

Try this one
 
Valli said:
Sub FindSheet()
Dim i As Integer
Name = InputBox("Please Enter the Name of the Worksheet to Find",
"SheetSearch", vbOKOnly)
For i = 1 To Worksheets.Count
If Application.ActiveWorkbook.Sheets(i).Name = Name Then
Application.ActiveWorkbook.Sheets(i).Select
End If
Next
End Sub

Try this one
-------

Tried, not work. when type name in input box and run, stay with no changes.
The main idea is make searching for worksheet name in spreadsheet much more
handy than gives us built-in Excel tool 'Find and Replace' that can easily
search within Sheet and Workbook, by Rows or by Column. As i understand,
custom search need be more handy and more simple compare with built-in one.

Regards,
S.
 

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