?
Solved

Select worksheet from data in Cell A1 not from Sheet Name

Posted on 2014-01-08
12
Medium Priority
?
385 Views
Last Modified: 2014-01-08
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
0
Comment
Question by:Jagwarman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 39764581
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
0
 

Author Comment

by:Jagwarman
ID: 39764617
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
0
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 39764626
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

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Jagwarman
ID: 39764641
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
0
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 39764655
Hi,

pls try example

TestOpen.xlsm

Regards
0
 

Author Comment

by:Jagwarman
ID: 39764729
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?
0
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 1500 total points
ID: 39764797
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
0
 

Author Comment

by:Jagwarman
ID: 39764851
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
0
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 39764854
I forgot to say that you have to close both files and reopen it to function

regards
0
 

Author Comment

by:Jagwarman
ID: 39764859
just a thought, when I open the file my macro is not then going to your code. What makes my Macro call your code?
0
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 39764930
My code initilize application events when you open it then every time you open a workbook the

App_WorkbookOpen code will be fired

Regards
0
 

Author Comment

by:Jagwarman
ID: 39765580
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
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question