ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search for worksheet name in Excel spreadsheet (https://www.excelbanter.com/excel-programming/400015-search-worksheet-name-excel-spreadsheet.html)

SANTANDER

Search for worksheet name in Excel spreadsheet
 
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.


Barb Reinhardt

Search for worksheet name in Excel spreadsheet
 
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

--
HTH,
Barb Reinhardt



"SANTANDER" wrote:

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.



[email protected]

Search for worksheet name in Excel spreadsheet
 
On Oct 25, 3:11 pm, "SANTANDER" wrote:
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").Activat e

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


SANTANDER

Search for worksheet name in Excel spreadsheet
 

wrote in message
ups.com...
On Oct 25, 3:11 pm, "SANTANDER" wrote:
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").Activat e


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


Valli

Search for worksheet name in Excel spreadsheet
 
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


SANTANDER

Search for worksheet name in Excel spreadsheet
 

"Valli" wrote in message
oups.com...
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.



All times are GMT +1. The time now is 11:38 PM.

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