![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 20
|
I have this formula
If Textbox1 = "" Then MsgBox "Field must be answered before you can proceed" Exit Sub End If This prevents the next stage when Ok is pressed however th rest of the macro still contiues how do I stop the macro when the cell is blank? |
|
|
|
|
|
#2 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Are you calling this from another Procedure?? The Exit Sub will exit the Procedure it is housed in but go straight back to the calling procedure. You could use
The End statement instead but this would unload the UserForm (if you are using one) and destroy all variables. Use a Boolean at the Project level. EG At the very top of a standard module put: Public bCarryOn as Boolean Then use: bCarryOn= True If Textbox1 = "" Then MsgBox "Field must be answered before you can proceed" bCarryOn= True Exit Sub End If And then use a simple If statement in your calling Procedure to Exit that Sub if it's True. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|