+ Reply to Thread
Results 1 to 16 of 16

Stop macro after 1 application

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

    Stop macro after 1 application

    If I change J1 to 1 it runs the macro once, if I change it to 1 again it runs the macro again.
    What can I add to the code to only allow it to run once.
    Something like stop recording_macro if J1=1

    Please Login or Register  to view this content.
    Thanks

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Stop macro after 1 application

    Hi, add a value to another cell, for example TRUE or FALSE
    When you change th value in the cell to 1 it checks if the value is TRUE (or FALSE) and depending on your choice you can either let it perform the macro or skipt it.
    Hope my answers makes sense to you
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Stop macro after 1 application

    Quote Originally Posted by parbynat View Post
    What can I add to the code to only allow it to run once.
    Something like stop recording_macro if J1=1
    more than likely, the answer is:
    Please Login or Register  to view this content.
    Last edited by AliGW; 09-05-2020 at 10:33 AM. Reason: Please don't quote unnecessarily!

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Stop macro after 1 application

    If the OP only wants the macro to run ONCE, then this won't work, the moment you change J1 to 0 and then back to 1 ...

  5. #5
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Stop macro after 1 application

    Quote Originally Posted by Keebellah View Post
    If the OP only wants the macro to run ONCE, then this won't work, the moment you change J1 to 0 and then back to 1 ...
    they will get back to us. more than likely, they have no idea what they want. I see this all day long everyday. just wait...

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Stop macro after 1 application

    True; people have difficulty explaining something to someone in such a manner that it's clear to the reader.
    Assumptions are the result and these on their part are killing.
    I quit basing my answers on assumptions

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

    Re: Stop macro after 1 application

    Thanks for the replies

    VBA_php, I used your code and I got a compile error, Else without if.

    Keebellah, Sorry my know how is low can you break it down a bit for me.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Stop macro after 1 application

    I think this is an oops
    Please Login or Register  to view this content.
    This should do it

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Stop macro after 1 application

    You still didn't answer if it's a one-time action or not

  10. #10
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Stop macro after 1 application

    get back to Keebellah. if he can't help, then you can ask me. my code works fine. maybe the words have to be on different lines.

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

    Re: Stop macro after 1 application

    Can you check I got this right Keebellah

    Please Login or Register  to view this content.
    Yes I want it to work only once

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Stop macro after 1 application

    Vba_php: your mistake is the exit sub and the else
    To answer about the macro, read it yourself, that’s NOT what’ I posted you’re testing J1 = 1 teiceyy

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

    Re: Stop macro after 1 application

    If the code is correct when I make J1 1 it starts the macro as I want but when I change it 2 it starts the macro again. Also when I use 1 again it also starts the macro.

    My aim is to make empty cell J1 1 and for that to start the macro, then if I key in 1 again I want nothing to happen and nothing to happen if I use any other value.

  14. #14
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Stop macro after 1 application

    Quote Originally Posted by parbynat View Post
    My aim is to make empty cell J1 1 and for that to start the macro, then if I key in 1 again I want nothing to happen and nothing to happen if I use any other value.
    I'm not following what you're saying. I do apologize. I would recommend that you work with Keebellah. an if statement is very basic, but it doesn't sound like that's what you need. good luck.

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

    Re: Stop macro after 1 application

    Appreciate your time vba_php

    I have spent so much time trying to get this to work

    I have a button set up also that when pressed works just as I want. If only I could activate that button when a certain cell is of a certain value but I can't and have to go down the road I'm on.

    Fun and games using excel when you lack knowledge

  16. #16
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Stop macro after 1 application

    Please Login or Register  to view this content.

+ 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. [SOLVED] Stop application.sum from rounding values from filtered range
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2019, 09:52 AM
  2. Application.ontime to stop at a certain time
    By rey745 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-14-2019, 10:36 AM
  3. [SOLVED] Stop a VBA Timer (Application.OnTime) on Separate Button Click.
    By KomicJ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-09-2018, 01:05 AM
  4. [SOLVED] Run Macro at set time - Stop them when workbook is closed. Application.OnTime
    By Si-Phy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2017, 06:14 AM
  5. How to Stop Application.Ontime from Running
    By shakira in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-24-2015, 08:14 AM
  6. Stop application.ontime
    By Onweerwolf in forum Excel General
    Replies: 5
    Last Post: 09-01-2014, 11:21 AM
  7. Replies: 15
    Last Post: 12-09-2009, 08:46 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