Results 1 to 4 of 4

Thread: Run a Macro when a cell is changed

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Acolyte tigerdel's Avatar
    Join Date
    Aug 2012
    Location
    Cambridgeshire
    Posts
    39
    Articles
    0
    Excel Version
    Office 365

    Run a Macro when a cell is changed

    Good Day to you all

    I have a dilema

    I have this code:
    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$2" Then
    Sheets("Sales").Range("All_Data").AdvancedFilter Action:=xlFilterCopy, _
    CriteriaRange:=Range("Criteria"), _
    CopyToRange:=Range("Extract"), _
    Unique:=False
    End If
    End Sub
    It is in Sheet = Company

    I also need to run the same code in Sheet = Broker and also Sheet = Party

    I built the same code but changed it to meet the requirements of the Sheet [Broker]:

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$2" Then
    Sheets("Sales").Range("DATA").AdvancedFilter Action:=xlFilterCopy, _
    CriteriaRange:=Sheets("Broker").Range("Criteria_Broker"), _
    CopyToRange:=Sheets("Broker").Range("Extract_Broker"), _
    Unique:=False
    End If
    End Sub
    The named ranges are built but although I receive no errors, no data is populated in Sheet [Broker]

    Any ideas because I am now completely frustrated

    Thanks for looking

    I can share the workbook if anyone wants it

  2. #2
    Acolyte tigerdel's Avatar
    Join Date
    Aug 2012
    Location
    Cambridgeshire
    Posts
    39
    Articles
    0
    Excel Version
    Office 365
    To clarify:
    The first code works absolutely fine in the Company sheet but the second code does not fill the sheet and gives no errors

  3. #3
    Acolyte Fluff's Avatar
    Join Date
    Sep 2018
    Posts
    74
    Articles
    0
    Excel Version
    2013
    Is that second code in the "Broker" sheet module?

  4. #4
    Administrator AliGW's Avatar
    Join Date
    Nov 2015
    Location
    Ipswich, Suffolk, England
    Posts
    1,205
    Articles
    0
    Excel Version
    Office 365 Subscription
    CROSS POST

    This question has been posted in at least one other forum.
    Do not post any further responses in this thread until a link has been provided to these cross posts.

    Whilst we would rather you didn't cross-post, we know that there may be a valid reason for doing so. All we ask is that you provide the links in your original post to your question in the other forum(s). Read this to understand why: https://www.excelguru.ca/content.php?184

    This forum is full of volunteers that give up their own time to help others, something that should be respected and not taken for granted. It’s never nice for someone to find out that a problem they have spent time solving for you has already been answered somewhere else without them knowing, and so we ask you to make it clear that you have also asked elsewhere.
    Please provide the link(s). If you are unable to do so, tell us where else you have posted this query.
    Ali
    Enthusiastic self-taught user of MS Excel!

Posting Permissions

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