+ Reply to Thread
Results 1 to 5 of 5

Stop a process early or middle and exit procedure if requirement is not fullfilled

  1. #1
    Registered User
    Join Date
    01-11-2020
    Location
    Norway
    MS-Off Ver
    Microsoft Office 2019
    Posts
    74

    Stop a process early or middle and exit procedure if requirement is not fullfilled

    Hi!

    I was wondering if there were any way to stop a script in the middle of the process, display a text box on why the script has stopped and then exit the procedure (without finishing the procedure).

    I understand that I of course have to write the text in the box myself.


    An example could be:

    If you have an operation that transfer a value that the user is supposed to write to another sheet, which then delivers several other values based on the first value you wrote to another sheet that is supposed to perform a calculation. If that value is not written you will get an error message "Run time error 1004", which pass you back to the code.
    I want to stop the script before that to tell the user to input numbers on the right places.

    Preferably the message should be something like " Input values in either Cell D4 or the cell range: G4,H4,I4".
    Then exit the script.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Stop a process early or middle and exit procedure if requirement is not fullfilled

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    01-11-2020
    Location
    Norway
    MS-Off Ver
    Microsoft Office 2019
    Posts
    74

    Re: Stop a process early or middle and exit procedure if requirement is not fullfilled

    Thank you for your assistance! I greatly appreciate it.

    I tried your code and I need to ask for some minor adjustments.

    So, one of the cells is a formula, and the formula shows: "#DIV/0!" When it is not getting the right inputs (as it gets from the other cells).
    Is it possible to add that one to your code as well? I only get an error from excel when the cell show this value.

    Also, is it possible to make the code in such manner that:

    EC = Array("D4", "G4", "H4", "I4")

    The D4 cell has to have a value, but it is not necessary that G4, H4 and I4 has a value. Could you please help me with this?

    The most important one is solving the "#DIV/0!" issue

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Stop a process early or middle and exit procedure if requirement is not fullfilled

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-11-2020
    Location
    Norway
    MS-Off Ver
    Microsoft Office 2019
    Posts
    74

    Re: Stop a process early or middle and exit procedure if requirement is not fullfilled

    Thanks again for replying, highly appreciated!

    So, I think you meant to write "Range("I4") on the last one in the second row in your code?

    When I write your code I seem to get the following error:

    "Run-time error '13':
    Type mismatch

    Edit: And it points me to the second row:

    If Range("F2").Value = "" And Range("K2").Value & Range("L2").Value & Range("M2").Value = "" Then



    Just to clarify, I use different cells than you.


    Second edit: When I removed the "#DIV/0!" from the cell, the code worked!

    The problem seems to be when the formula given by the cells K2, L2 and M2 to cell F2 is messed up and the cell gets the "#DIV/0!" value, the code won't work.
    Last edited by -Citizen; 02-23-2020 at 05:45 PM.

+ 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. start java process then exit vb
    By cmccabe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-23-2015, 06:12 PM
  2. [SOLVED] Exit Sub Procedure when called on Sub Procedure Exits
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2015, 08:17 AM
  3. [SOLVED] Coding Convention Questions #4 (One and only one exit from a procedure)
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2014, 08:20 PM
  4. If condition fullfilled exit sub
    By fatalcore in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-25-2011, 11:35 AM
  5. to exit main procedure from procedure called by yhe main
    By kmlprtsngh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2010, 02:46 PM
  6. Counter changes value n the middle of the process
    By burugudug in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2010, 11:59 PM
  7. [SOLVED] What is procedure to exit formula auditing mode?
    By W8 in forum Excel General
    Replies: 3
    Last Post: 02-14-2005, 05:06 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