none
Trigger a macro based on a change on a list RRS feed

  • Question

  • Hi...I'm trying to execute a macro to update a pivot only when a value in a list changes. I'm using

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    and the Intersect function, but I can't make it work as in the moment I click on the cell that contains the list the pivot refreshes and then if I change its value, nothing happens. The list is on the cell C5 and I need the macro only executes when I change some value in that list.

    Any help would be appreciated

    Thanks,

    Ezequiel

    Thursday, November 9, 2017 10:14 PM

All replies

  • If you want to react to a change in value, you should use the Worksheet_Change event instead of the Worksheet_SelectionChange event.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Thursday, November 9, 2017 10:28 PM
  • Hi Ezequiel,

    Has your issue been resolved by the suggestion from Hans? As Hans said, you should use Worksheet_Change.

    Here is a simple code.

    Private Sub Worksheet_Change(ByVal Target As Range)
        Debug.Print Target.Address
        If (Target.Address = "$C$5") Then
            MsgBox "Value Change"
        End If
    End Sub

    If you have any issue about this, please let us know.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 17, 2017 9:24 AM