Solved

Define a sheet name to be returned to later.

Posted on 2011-02-25
8
217 Views
Last Modified: 2012-05-11
I need to leave a current sheet and return to it. How do I set this up? I have tried many different ways, but can't seem to get it to work.
Dim CurSht As Worksheet
  
  Set CurSht = ActiveSheet
   MsgBox "current sheet=" & CurSht

Open in new window

0
Comment
Question by:CRHIV
8 Comments
 
LVL 6

Accepted Solution

by:
FernandoFernandes earned 25 total points
ID: 34981654
You can do it with Ctrl+PgUp and Ctrl+PgDown
also, the code you wrote is not good...
it should be like this, but anyway, it doesn't do what you want it to do... it just pops the activesheet's name...
Dim CurSht As Worksheet
  
  Set CurSht = ActiveSheet
   MsgBox "current sheet=" & CurSht.Name

Open in new window

0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 34981819
to return to it later...


Dim CurSht As Worksheet
  
  Set CurSht = ActiveSheet

'more code

CurSht.Select

Open in new window

0
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 25 total points
ID: 34981826
A little better:



Dim CurSht As Worksheet
  
  Set CurSht = ActiveSheet

'more code

With CurSht
    .Parent.Activate
    .Select
End With

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:CRHIV
ID: 34983262
I saved the variable CurSht to another sheet that the user has to check for changes, then send to the printer. I can't get the program to recognize the CurSht variable again.
Unload Me
        Sheets("napa").Select
        Sheets("NAPA").Range("K23") = CurSht
End Sub




Sub Rectangle124_Click()
    Dim CurSht As String
    Dim STDprinter As String
    CurSht = Range("K23").Value
    STDprinter = Application.ActivePrinter
    Application.ActivePrinter = "OKI MICROLINE 1120 on Ne00:"
    Sheets("NAPA").PrintOut
    Application.ActivePrinter = STDprinter                'change back to standard printer
   MsgBox "Current Sheet=" & CurSht
    Sheets(CurSht).Select

End Sub

Open in new window

0
 

Author Comment

by:CRHIV
ID: 34983797
After working with it some more, It's picking it up. But the code seems to stop after printing the document.
When it gets to the Rectangle124_click(), I don't get any MsgBox replies.
Unload Me
        Sheets("napa").Select
        Sheets("NAPA").Range("K23") = CurSht
        CurSht = ""
        MsgBox "cursht=" & CurSht
        
        CurSht = Range("K23")

        MsgBox "CurSht=" & CurSht

End Sub

'Does not work below here, except for the print


Sub Rectangle124_Click()
    Dim CurSht As String
    Dim STDprinter As String
    CurSht = Range("K23")
    STDprinter = Application.ActivePrinter
    Application.ActivePrinter = "OKI MICROLINE 1120 on Ne00:"
    Sheets("NAPA").PrintOut
    Application.ActivePrinter = STDprinter                'change back to standard printer
    MsgBox "CurSht=" & CurSht
    Sheets("CurSht").Select
    MsgBox "CurSht=" & CurSht
    Sheets("Sheet7").Select


End Sub

Open in new window

0
 

Author Comment

by:CRHIV
ID: 34984799
Never mind, Had the sub in two places.

Thanks for your help.
0
 
LVL 24

Expert Comment

by:broomee9
ID: 35225362
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now