Select worksheet from data in Cell A1 not from Sheet Name

Is it possible to select a worksheet from text that is in Cell A1?

Reason: Sheet names are often different but Cell A1 will always be consistant, So, if the text I am looking for is Document it could be on any of the worksheets I need to select A1 on the Worksheet with Document in A1 when my Macro opens the Workbook,

Possible???????

Thanks
JagwarmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

You could try (but beware of duplicates) in your worbook module

Private Sub Workbook_Open()
    For Each sh In Me.Worksheets
       If sh.Range("A1") = "Document" Then
           sh.Range("A1").Activate
       End If
    Next
End Sub

Open in new window

Regards
JagwarmanAuthor Commented:
Hi Rgonzo1971

thanks for getting back so quickly. Unfortunately it does not seem to work.

I open the workbook which open on Sheet1, the macro then runs and ends but stays on sheet1 whereas it should end up on Sheet 4
Rgonzo1971Commented:
Hi,

Sorry let's try

Private Sub Workbook_Open()
    For Each sh In Me.Worksheets
       If sh.Range("A1") = "Document" Then
            sh.Activate
            Range("A1").Activate
       End If
    Next
End Sub

Open in new window

CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

JagwarmanAuthor Commented:
Unfortunately that is not working either. I have also gone to the sheet that I want to start at and placed the curser in a random cell expecting the macro to go to A1.... but nope. Bizzare
Rgonzo1971Commented:
Hi,

pls try example

TestOpen.xlsm

Regards
JagwarmanAuthor Commented:
I presume your file works because the macro is in that file whereas my macro is in a different workbook.

In my workbook I need to open a file that was saved down by someone else [which is a new file every day] and when my workbook opens the file that is when I need it to find the Sheet with the text Document,

I guess this is more complicated as I am not sure I can call a private sub from within my Macro. Or can I?
Rgonzo1971Commented:
Hi,

pls try this in the ThisWorkbook Module of the Excel file you use to open the file

Public WithEvents App As Application

Private Sub Workbook_Open()
    Set App = Application
End Sub

Private Sub App_WorkbookOpen(ByVal Wb As Workbook)

    For Each sh In Wb.Worksheets
       If sh.Range("A1") = "Document" Then
            sh.Activate
            Range("A1").Activate
       End If
    Next
End Sub

Open in new window

Regards

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JagwarmanAuthor Commented:
Rgonzo1971.

Still not working,

Think we are going to have to give up on this one I have taken up too much of your time already.

Regards
Rgonzo1971Commented:
I forgot to say that you have to close both files and reopen it to function

regards
JagwarmanAuthor Commented:
just a thought, when I open the file my macro is not then going to your code. What makes my Macro call your code?
Rgonzo1971Commented:
My code initilize application events when you open it then every time you open a workbook the

App_WorkbookOpen code will be fired

Regards
JagwarmanAuthor Commented:
Rgonzo1971

I cannot get this to do what I want it to do, but, it is a macro I will be able to use under different curcumstances so I am going to accept
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.