+ Reply to Thread
Results 1 to 5 of 5

can OnEntry be limited to certain cells only??

  1. #1
    Registered User
    Join Date
    11-29-2004
    Posts
    17

    can OnEntry be limited to certain cells only??

    I can use OnEntry to trigger a macro when any cell on a given sheet is edited --

    Sub Auto_Open()
    Worksheets("Sheet1").OnEntry = "TriggeredMacro"
    End Sub

    Is there a way to limit the triggering to just certain cells? so that only editing in those cells initiates the macro?

    Thanks in advance ...

  2. #2
    Jim May
    Guest

    Re: can OnEntry be limited to certain cells only??

    example from Help:

    Worksheets("Sheet1").Activate
    Set isect = Application.Intersect(Range("rg1"), Range("rg2"))
    If isect Is Nothing Then
    MsgBox "Ranges do not intersect"
    Else
    isect.Select
    End If




    "Chief Wiggums" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > I can use OnEntry to trigger a macro when any cell on a given sheet is
    > edited --
    >
    > Sub Auto_Open()
    > Worksheets("Sheet1").OnEntry = "TriggeredMacro"
    > End Sub
    >
    > Is there a way to limit the triggering to just certain cells? so that
    > only editing in those cells initiates the macro?
    >
    > Thanks in advance ...
    >
    >
    > --
    > Chief Wiggums
    > ------------------------------------------------------------------------
    > Chief Wiggums's Profile:
    > http://www.excelforum.com/member.php...o&userid=16934
    > View this thread: http://www.excelforum.com/showthread...hreadid=516531
    >




  3. #3
    Registered User
    Join Date
    11-29-2004
    Posts
    17

    re: can OnEntry be limited to certain cells only??

    Hmmm ... I'm think this involves the Caller property, which can somehow be used to return the address of the cell whose editing triggered the macro.

    If I had that, then that could serve as Range("rg1") in the example you've given
    and it would work perfectly.

    Thanks very much, Jim.

  4. #4
    Registered User
    Join Date
    11-29-2004
    Posts
    17

    re: can OnEntry be limited to certain cells only??

    OK, the following seems to work:

    Set isect = Application.Intersect(Range(Application.Caller.Address), Range("rg2"))
    If isect Is Nothing Then
    MsgBox "Ranges do not intersect"
    Else
    isect.Select
    End If

    In this example, Application.Caller.Address returns the address of the cell which was edited. So one can test and then act, depending on whether that cell was a specified cell or not.

    THanks again, Jim.

  5. #5
    Jim May
    Guest

    Re: can OnEntry be limited to certain cells only??

    Thanks for the feedback

    "Chief Wiggums" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > OK, the following seems to work:
    >
    > Set isect = Application.Intersect(Range(Application.Caller.Address),
    > Range("rg2"))
    > If isect Is Nothing Then
    > MsgBox "Ranges do not intersect"
    > Else
    > isect.Select
    > End If
    >
    > In this example, Application.Caller.Address returns the address of the
    > cell which was edited. So one can test and then act, depending on
    > whether that cell was a specified cell or not.
    >
    > THanks again, Jim.
    >
    >
    > --
    > Chief Wiggums
    > ------------------------------------------------------------------------
    > Chief Wiggums's Profile:
    > http://www.excelforum.com/member.php...o&userid=16934
    > View this thread: http://www.excelforum.com/showthread...hreadid=516531
    >




+ 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