+ Reply to Thread
Results 1 to 2 of 2

How to indicate that the current visible worksheet is the active o

  1. #1
    George Furnell
    Guest

    How to indicate that the current visible worksheet is the active o

    Good day,

    I have a function in a module, in which I would like to state that the
    current visible worksheet should be treated as the active one, because I do
    not know during execution what the sheet name will be. In the example below
    the sheet name is hardcoded, what is the better solution?

    With ActiveWorkbook
    With .Worksheets("Titans")
    .Range("M5").Value = 5
    End With
    End With

    Kind regards

    George




  2. #2
    Norman Jones
    Guest

    Re: How to indicate that the current visible worksheet is the active o

    Hi George,

    Dim SH As Worksheet

    Set SH = ActiveSheet

    SH.range("M5").Value = 5

    The object variable SH will refer to the stipulated sheet, irrespective of
    whether it is subsequently active or not..


    ---
    Regards,
    Norman


    "George Furnell" <GeorgeFurnell@discussions.microsoft.com> wrote in message
    news:63CCD879-F9B3-4716-9589-12737D11DB91@microsoft.com...
    > Good day,
    >
    > I have a function in a module, in which I would like to state that the
    > current visible worksheet should be treated as the active one, because I
    > do
    > not know during execution what the sheet name will be. In the example
    > below
    > the sheet name is hardcoded, what is the better solution?
    >
    > With ActiveWorkbook
    > With .Worksheets("Titans")
    > .Range("M5").Value = 5
    > End With
    > End With
    >
    > Kind regards
    >
    > George
    >
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1