+ Reply to Thread
Results 1 to 10 of 10

Stop all macro's

Hybrid View

  1. #1
    Registered User
    Join Date
    02-27-2007
    Posts
    7

    Stop all macro's

    u guys helped me out realy nicely with my macro for copying data ever 2 seconds

    but now i need to make a button that Immidiately stops all macro's, Or (and This will maby be little more difficult) Stop all macros on a specific time inserted in 1 cell

    the macro's that i want to stop running, are all single macro's which i activate with only 1 button i created.

    i like something like this:

    if "A1"(this is the cell where i have my updated clock) == A2 (the time i insert here stops the macro's at this time) do stop Macro's

    i know this doesnt make any sence but now u have an idea

    Thanks in advance

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    If Range("A1").Value = Range("A2").Value then End
    HTH
    Carim


    Top Excel Links

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Rick

    Carim's suggested implemented into macro from your previous thread.

    Sub OnTimeCopyData()
       Dim lNextRow As Long
       
       If Range("A1").Value = Range("A2").Value Then
          End
       End If
       lNextRow = Cells(Rows.Count, "a").End(xlUp).Row + 1
       If lNextRow > Rows.Count Then
          MsgBox "Sheet Full - Cannot continue"
          End
       End If
       Range("a" & lNextRow & ":c" & lNextRow).Value = Range("a1:c1").Value
       Application.OnTime Now() + TimeValue("00:00:02"), "OnTimeCopyData"
    End Sub
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  4. #4
    Registered User
    Join Date
    02-27-2007
    Posts
    7
    thanks very much guys but isnt there a way to Stop all macro's with 1 button? maby by copieing the time in cell a1 to a2 so it will trigger the time macro?

  5. #5
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Private Sub CommandButton1_Click()
    End
    End Sub

  6. #6
    Registered User
    Join Date
    02-27-2007
    Posts
    7
    doesnt work, how to specify which macro you wanna end

  7. #7
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    You can not have 2 macros running at the same time.

    You can not run one macro to stop another macro directly.


    When no macros are already running you can run one macro that changes a setting like a variable or a cell value

    The other macros would need to test the value of that setting and if it equals required value then runs an end or exit sub command.


    This is what this part of the code is for

    If Range("A1").Value = Range("A2").Value Then
         End
     End If
    With the above code it would not work unless the 2 times were exact it probally should be

    
    If Range("A1").Value >= Range("A2").Value Then
         End
     End If

+ 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