ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to end when test condition met? (https://www.excelbanter.com/excel-programming/339443-how-end-when-test-condition-met.html)

davegb

How to end when test condition met?
 
I have a test in my program,

If strOrig < "DYC" Or "" Then

After the code below runs, I want the macro to end when strOrig = DYC
or is blank. How do I tell it to end?


cody

How to end when test condition met?
 
Try adding the exit sub command after the if statement in the macro code.

"davegb" wrote:

I have a test in my program,

If strOrig < "DYC" Or "" Then

After the code below runs, I want the macro to end when strOrig = DYC
or is blank. How do I tell it to end?



Rowan[_8_]

How to end when test condition met?
 
Have you tried:

If strOrig < "DYC" Or "" Then Exit Sub

You need to be carefull doing this though as if you have changed any
application settings eg screenupdating, displayalerts they will not be
reset if you simply exit.

Regards
Rowan

davegb wrote:
I have a test in my program,

If strOrig < "DYC" Or "" Then

After the code below runs, I want the macro to end when strOrig = DYC
or is blank. How do I tell it to end?


Rowan[_8_]

How to end when test condition met?
 
Sorry, I think that should have been:

If strOrig = "DYC" Or strOrig = "" Then Exit Sub

Rowan wrote:
Have you tried:

If strOrig < "DYC" Or "" Then Exit Sub

You need to be carefull doing this though as if you have changed any
application settings eg screenupdating, displayalerts they will not be
reset if you simply exit.

Regards
Rowan

davegb wrote:

I have a test in my program,

If strOrig < "DYC" Or "" Then

After the code below runs, I want the macro to end when strOrig = DYC
or is blank. How do I tell it to end?



All times are GMT +1. The time now is 12:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com