+ Reply to Thread
Results 1 to 3 of 3

SelectionChange event

  1. #1
    Hayeso
    Guest

    SelectionChange event

    When I change selectio in a worksheet, the range that I select is passed to
    the SelectionChange event as Target. How can I identify the range that I have
    changed from?

  2. #2
    Tom Ogilvy
    Guest

    Re: SelectionChange event

    You would need to put in a static variable in the selectionchange event and
    update it as you exit the selectionchange event.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim oldSelection as Static

    ' code that does things


    set OldSelection = Target

    End Sub

    if you will have to use this value on the very first selectionchange, then
    you will need to make it a public variable in a general module and
    initialize it in the Workbook_Open event.

    --
    Regards,
    Tom Ogilvy


    "Hayeso" <[email protected]> wrote in message
    news:[email protected]...
    > When I change selectio in a worksheet, the range that I select is passed

    to
    > the SelectionChange event as Target. How can I identify the range that I

    have
    > changed from?




  3. #3
    Hayeso
    Guest

    Re: SelectionChange event

    Thanks Tom, That makes sense.

    "Tom Ogilvy" wrote:

    > You would need to put in a static variable in the selectionchange event and
    > update it as you exit the selectionchange event.
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > Dim oldSelection as Static
    >
    > ' code that does things
    >
    >
    > set OldSelection = Target
    >
    > End Sub
    >
    > if you will have to use this value on the very first selectionchange, then
    > you will need to make it a public variable in a general module and
    > initialize it in the Workbook_Open event.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Hayeso" <[email protected]> wrote in message
    > news:[email protected]...
    > > When I change selectio in a worksheet, the range that I select is passed

    > to
    > > the SelectionChange event as Target. How can I identify the range that I

    > have
    > > changed from?

    >
    >
    >


+ 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