+ Reply to Thread
Results 1 to 10 of 10

Run Excel Macro IF certain condition is met, else exit Macro

  1. #1
    Forum Contributor
    Join Date
    04-20-2011
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2007
    Posts
    121

    Run Excel Macro IF certain condition is met, else exit Macro

    This Macro works fine but I need it NOT to run if a certain condition is met.
    When worksheet "Mileages" opens Cell I2 has todays date in it. Column J is a list of consecutive dates past and future.
    Can someone modify the Macro so that it only runs if the date in Column J is a past Date.

    Thanks in advance

    Chambo


    Please Login or Register  to view this content.
    Last edited by Martin Chamberlin; 04-27-2014 at 02:00 AM.
    Chambo1160

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Run Excel Macro IF certain condition is met, else exit Macro

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  3. #3
    Forum Contributor
    Join Date
    04-20-2011
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2007
    Posts
    121

    Re: Run Excel Macro IF certain condition is met, else exit Macro

    Thanks for the notice. Not sure if I have it right yet but I hit the # key as requested. Can you advise/help please.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Run Excel Macro IF certain condition is met, else exit Macro

    Your post should look
    Please Login or Register  to view this content.
    Select code and then click # above.
    CT.png

  5. #5
    Forum Contributor
    Join Date
    04-20-2011
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2007
    Posts
    121

    Re: Run Excel Macro IF certain condition is met, else exit Macro

    Sorted. Post edited as requested.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Run Excel Macro IF certain condition is met, else exit Macro

    Date is in Column J or Column K as in the code?

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Run Excel Macro IF certain condition is met, else exit Macro

    Maybe this?

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    04-20-2011
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2007
    Posts
    121

    Re: Run Excel Macro IF certain condition is met, else exit Macro

    The date is in Column J. The Macro adds the date into J and also copies a corresponding value in Column K.

    Where in the Macro do I add your code? Help is much appreciated.

  9. #9
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Run Excel Macro IF certain condition is met, else exit Macro

    It's new macro. You don't add in previous one.
    If it doesn't work can you upload example workbook?
    Make sure to remove all private informations.

  10. #10
    Forum Contributor
    Join Date
    04-20-2011
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2007
    Posts
    121

    Re: Run Excel Macro IF certain condition is met, else exit Macro

    File attached. Just hit the button in J1. Password protected safe

    Thanks
    Attached Files Attached Files

+ 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. EXCEL: Exit Sub If Particular Macro Is Already Run
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2013, 04:52 AM
  2. Replies: 8
    Last Post: 10-30-2010, 08:07 PM
  3. Exit Schema Macro after condition..
    By xmux in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2009, 07:51 AM
  4. [SOLVED] macro wants to exit excel
    By curlydave in forum Excel General
    Replies: 3
    Last Post: 07-02-2006, 11:25 AM
  5. Write macro don't ask to save when exit excel
    By Rui Alvares in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2006, 07:55 PM

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