+ Reply to Thread
Results 1 to 6 of 6

Stop macro that keeps firing

Hybrid View

  1. #1
    Registered User
    Join Date
    06-16-2018
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    138

    Stop macro that keeps firing

    Can someone help with this?

    I have a button attached to a macro that works fine, if I click it manually it does exactly as I want.

    I have just tried to activate this macro from the worksheet, as shown

    HTML Code: 
    I have J1 cell showing 0 then when I change it to 1 it starts the marco and continues to activate it which is messing everything up.
    How would I edit this so that 0 does nothing then when the value changes from 0 the macro fires once and then fires again when the value changes again.

    Thanks

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Stop macro that keeps firing

    Difficult to say without knowing what's in the called macro, but I think it's running over and over because the called macro changes the sheet and that sets it off again.
    If that's the case, try this.

    Private Sub Worksheet_Change(ByVal Target As Range)
        Application.EnableEvents = False
        If Range("J1") = 1 Then Call Recording_macro
        Application.EnableEvents = True
    End Sub
    BSB

  3. #3
    Registered User
    Join Date
    06-16-2018
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    138

    Re: Stop macro that keeps firing

    BSB that has worked fine, many thanks.
    When the value gets changed to 1 from any other number it kicks in the macro only once.
    How could I edit again so that the macro kicks in on any value change?

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Stop macro that keeps firing

    Maybe this?

    Private Sub Worksheet_Change(ByVal Target As Range)
        Application.EnableEvents = False
        If Not Intersect(Range("J1"), Target) Is Nothing Then Call Recording_macro
        Application.EnableEvents = True
    End Sub
    BSB

  5. #5
    Registered User
    Join Date
    06-16-2018
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    138

    Re: Stop macro that keeps firing

    Spot on.
    Thank you

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Stop macro that keeps firing

    No problem. Happy to help

    BSB

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Worksheet Change Event Not Firing / Worksheet Calculate Repetitive Firing
    By huyza_0100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2019, 04:58 PM
  2. [SOLVED] Firing a COM Add in macro
    By Bishonen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-18-2015, 03:29 PM
  3. Public Function won't stop firing
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2014, 08:20 PM
  4. Stop exit event of textbox firing when click a command button to close a userform
    By chrisjames25 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-18-2013, 09:27 AM
  5. Macro not firing off
    By Hiran de Silva in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2006, 03:30 PM
  6. [SOLVED] How to stop UDF firing when sheets(n).calculate
    By David in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-20-2005, 07:06 AM
  7. [SOLVED] Stop Worksheet_SelectionChange event from firing?
    By Ed in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-05-2005, 09:06 AM

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