Code needed to Exit sub early depending on criteria.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paul138
    New Member
    • Dec 2009
    • 5

    Code needed to Exit sub early depending on criteria.

    Hi,

    I have created an index in Excel that goes up by 1 everytime a macro is run. (cell c99 in Sheet1)

    I.e. it starts at one, i run the macro and it now shows 2.

    I wish to add some code to my macro which doesnt allow this addition to happen anymore, once my index number has reached 5, and for the macro to exit sub early.

    So once the index reaches five, i wish for a message box to appear telling the user that this cant be done as the index is now too high, and for the code to exit sub prematurely.

    Hope this makes sense and

    Hope you can help,

    Thank you very much!
    P.
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    dear,

    I hope this will help you (see attachment)

    br,
    Attached Files

    Comment

    • paul138
      New Member
      • Dec 2009
      • 5

      #3
      Thank you very much!!

      just what i needed :-)

      Comment

      Working...