Consulting

Results 1 to 3 of 3

Thread: If current sheet is...

  1. #1
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location

    If current sheet is...

    Hi,

    Okay, I here expose my thickoness to you all...

    In vba, how to I say correctly "If the current sheet is "mySheet1" then do this, otherwise, If the current sheet is "mySheet2" then do that?

    Thanks my, er, gurus
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

  2. #2
    VBAX Mentor Marcster's Avatar
    Joined
    Jun 2005
    Posts
    434
    Location
    Hi Babydum,

    Try this:


    If ThisWorkbook.ActiveSheet.Name = "mySheet1" Then
    MsgBox "Active sheet is mySheet1"
    ElseIf ThisWorkbook.ActiveSheet.Name = "mySheet2" Then
    MsgBox "Active sheet is mySheet2"
    Else
    MsgBox "Neither mySheet1 or mySheet2"
    End If

    Marcster.

  3. #3
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location
    Poifect! Thanks!!
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

Posting Permissions

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