Results 1 to 4 of 4

Excel VBA Active WorkSheet Name

This is a discussion on Excel VBA Active WorkSheet Name within the Excel Questions forums, part of the Question Forums category; I would like to find out the WorkSheet Name Of the Current work sheet so that I may check it ...

  1. #1
    New Member
    Join Date
    Mar 2007
    Posts
    23

    Default Excel VBA Active WorkSheet Name

    I would like to find out the WorkSheet Name Of the Current work sheet so that I may check it to see if the user is on the right WorkSheet.

    If variable <> "RIGHT" Then
    I then want to make the correct sheet active using the name I just tested for.

  2. #2
    MrExcel MVP Jonmo1's Avatar
    Join Date
    Oct 2006
    Location
    Bryan, TX
    Posts
    32,537

    Default

    x = ActiveSheet.Name
    If x <> "RIGHT" then Sheets("RIGHT").Select


    Although, it might be simpler just to select the correct sheet, rather than test if the right sheet is selected first...

    Sheets("RIGHT").Select

    It will not error if the RIGHT sheet is already active..
    Want better/faster responses to your questions?
    Use Excel Jeanie to post samples of your sheet.

    The more we learn, and the better we get at our trade, the easier it becomes to overlook the obvious.

    Life moves pretty fast. If you don't stop and look around once in a while, you could miss it.
    Ferris Bueller A.K.A. John Hughes, 1986

  3. #3
    Board Regular ADAMC's Avatar
    Join Date
    Mar 2007
    Location
    UK
    Posts
    1,094

    Default

    Sub testme()
    Mysheet = ActiveSheet.name
    If Mysheet <> "Sheet1" Then Sheets("Sheet1").Activate
    End Sub

    But if the user only needs one sheet why not activate that in a workbook open or something?
    ADAMC (",)

    If everything seems to be going well, you have obviously overlooked something.

  4. #4
    New Member
    Join Date
    Mar 2007
    Posts
    23

    Default

    Thanks WORKS FINE.. I could not find it anywhere

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com