search all open workbooks for sheet name

R

Rick Rothstein

Give this code a try...

Sub GotoSheetA1onSheetNamedX()
Dim WB As Workbook
On Error Resume Next
For Each WB In Application.Workbooks
WB.Worksheets("X").Activate
WB.Worksheets("X").Range("A1").Select
Next
End Sub

Change all the X's to the actual name of the sheet you want to go to.
 
J

J.W. Aldridge

trying to find workbook with worksheet that has same name. Ending of
name may vary, but starts off as code indicates.
Code doesn't work... any clues?

Sub GotoSheetA1onSheetNamedX()
Dim wb As Workbook
On Error Resume Next
For Each wb In Application.Workbooks
wb.Worksheets("2ndex_to*").Activate
wb.Worksheets("2ndex_to*").Range("A1").Select
Next
End Sub
 
R

Rick Rothstein

You have to give us *all* the information regarding your problem in order
for us to give you code that you can use. It is almost always a bad idea to
simplify your examples or needs when you ask questions on newsgroups.

Give this code a try...

Sub GotoSheet()
Dim WB As Workbook
Dim WS As Worksheet
On Error Resume Next
For Each WB In Application.Workbooks
For Each WS In WB.Worksheets
If WS.Name Like "2ndex_to*" Then
WS.Activate
WS.Range("A1").Select
End If
Next
Next
End Sub
 

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

Top