+ Reply to Thread
Results 1 to 5 of 5

How to stop code,look at a sheet, then continue the code

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    How to stop code,look at a sheet, then continue the code

    I am running code which queries some data and then gets this into a form that can be used by a dashboard. A little after the code has started I stop it with a msgbox with a Yes/No answer to the question "Do you need to add new NominalCodes?"
    If the answer is No the code continues if Yes then I want to open a specific worksheet make manual changes then click a button on the sheet to indicate that the changes are made and then to continue the code.
    My attempts, as can be seen in the attachment have been unsuccessful, and I need help.
    John
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to stop code,look at a sheet, then continue the code

    Here is an untested guess. On a sheet set up a range called ContinueFlag. This will take on the value of True or False.

    When you go through the code and answer yes, don't hide the sheet. unload it, set the flag to continue to TRUE and exit the subroutine.

    Go to the sheet and edit and relaunch the form. The flag is true, so it will skip to 10.

    The last thing the form does is reset the flag to False.
    Please Login or Register  to view this content.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: How to stop code,look at a sheet, then continue the code

    dflak,
    Many thanks for you interest in my problem. First I tried your code as it is with the addition of the flag sheet. Without success I am sorry to say. Then I thought that I had got two ways of flagging the need to leave sheet "AdjustedCC" and carry on with the code. Your "ContiueFlag" and my ButtoneClick which turns from FALSE to TRUE when the button on sheet"AdjustedCC is pressed and back to False again when the code finishes. So I tried modifying the code to use the button still with no success. In one way the code works by branching in the way I want but it does not stop when "AdjustedCC" is activated it just carries on to the end.
    I have called the edited copy Trial34. It has in it Sub NewYear 2 for the new code. I am attaching this in the hope that you may have patience and the time to look at it again.
    John
    Attached Files Attached Files

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: How to stop code,look at a sheet, then continue the code

    I don't think I can help since I do not have all the pieces. I'm getting errors because I don't have Sheet1 and Dash. Also there is apparently a database connection that I don't have access to.

  5. #5
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: How to stop code,look at a sheet, then continue the code

    I sent a part of the project because the whole thing exceeds the forum limit. I have now found a simple work round by giving the check for new nominal codes its own button, then the button on the sheet AdjustedCC sends you back to userForm1.
    Thanks very much for your help though.
    John

+ 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] Copy Sheet, Open Workbook, Paste and continue with code
    By ksayet in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-03-2015, 10:25 PM
  2. Running code more than once it stop and sheet exist.
    By Horseman70 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2015, 12:05 AM
  3. [SOLVED] Stop sheet vb code to run a print vb code.
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-20-2014, 03:14 PM
  4. [SOLVED] Code Efficiency: Stop from looking all the way to the bottom of sheet
    By mlegge04 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-03-2012, 01:12 PM
  5. [SOLVED] VBA Code (colums to row, autofill) stop working in row 294 when new cable code appear
    By sknifseht in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-29-2012, 05:27 AM
  6. [SOLVED] changing cell on active sheet does not cause code to continue - No error codes either
    By SoteriaLive in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-01-2012, 11:21 AM
  7. how to stop running vba code without loosing printed data on the sheet?
    By MCM in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2006, 05:10 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