Consulting

Results 1 to 6 of 6

Thread: Help - activate sheet

  1. #1
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location

    Help - activate sheet

    Hello,

    Im trying to activate a sheet within the workbook based on the cell 'G6'

    [vba]
    Sheets(Sheets("control").Range("g6").Value).Activate
    [/vba]

    What am I doing wrong???

    Example, if I have sheet names , yes, no , maybe, and the word maybe is in cell g6 , I would like the sheet 'maybe' to 'activate'

  2. #2
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    Please help! Im on a deadline and this is the only line holding me back! I will PAY someone!!

  3. #3
    VBAX Tutor david000's Avatar
    Joined
    Mar 2007
    Location
    Chicago
    Posts
    276
    Location

    You must use an event!

    [vba]
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Me.Range("a1").Value = "maybe" Then
    Sheet3.Activate
    End If

    End Sub
    [/vba]
    You can leave the sheet that contains the code, then return after some other code on the destination sheet later.

  4. #4
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    ?

    The sheet names are already in place, lets say name 1 through 12, and its going between files. The data need to know which sheet to dump the data dynamically . So if I say 'sheet' maybe , the other 11 sheets are out of luck.

  5. #5
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    Wait ... your right. It will work , I'll just need to specify the other 11 ... its messy, but I'll take it @!! Thank you.

  6. #6
    VBAX Tutor david000's Avatar
    Joined
    Mar 2007
    Location
    Chicago
    Posts
    276
    Location

    You can try...call the sheets by the user name sure!

    [VBA]
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Me.Range("a1").Value = "Maybe" Then
    Sheets("Maybe").Activate
    ElseIf Me.Range("a1").Value = "No" Then
    Sheets("No").Activate
    ElseIf Me.Range("a1").Value = "Yes" Then
    Sheets("Yes").Activate
    End If
    End Sub
    [/VBA]

Posting Permissions

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