![]() |
stopping a macro based on a conditional
Maybe it's just been a long day, but I can't remember how I've done
this in the past. I'm trying to have a macro stop based on a condition. It's coming from a form, but if things are done out of order in one spot, things go bad, so I'm trying to force the user into selecting a Week Beginning Date prior to checking a box. The week beginning date loads down to [Data!b2] so this macro is checking to see if there's anything there, if there is, it follows the code from there, if that cell is blank though, I want it to pop up a message, then return to the form (preferably without unloading and reloading the form as the user will lose all of their entries to that point). Any ideas? Here's what I've in this section now, If MultipleBox = True Then If [data!b2].Value = "" Then MsgBox "Choose Initial Request Week First" MultipleBox = False End Sub End If 'From here the remainder of the code goes . . . Now I'm sure it's not end sub, but i can't remember what goes there - i've tried stop (does nothing) and end function (gives an error, then does nothing). Basically all i'm looking for is this, when the box is checked (this is in the MultipleBox_AfterUpdate) if it's true, check to see that the week beginning date has been selected, if that cell is blank - pop up a message - set the box back to unchecked - stop this macro while leaving the form running. Can someone point me back in the right direction? |
stopping a macro based on a conditional
im really new to VBA, but are you refering to "Exit Sub"? -- MC82 ------------------------------------------------------------------------ MC82's Profile: http://www.excelforum.com/member.php...o&userid=18682 View this thread: http://www.excelforum.com/showthread...hreadid=540056 |
stopping a macro based on a conditional
How about "Exit Sub"?
-- Ken Hudson "Craig" wrote: Maybe it's just been a long day, but I can't remember how I've done this in the past. I'm trying to have a macro stop based on a condition. It's coming from a form, but if things are done out of order in one spot, things go bad, so I'm trying to force the user into selecting a Week Beginning Date prior to checking a box. The week beginning date loads down to [Data!b2] so this macro is checking to see if there's anything there, if there is, it follows the code from there, if that cell is blank though, I want it to pop up a message, then return to the form (preferably without unloading and reloading the form as the user will lose all of their entries to that point). Any ideas? Here's what I've in this section now, If MultipleBox = True Then If [data!b2].Value = "" Then MsgBox "Choose Initial Request Week First" MultipleBox = False End Sub End If 'From here the remainder of the code goes . . . Now I'm sure it's not end sub, but i can't remember what goes there - i've tried stop (does nothing) and end function (gives an error, then does nothing). Basically all i'm looking for is this, when the box is checked (this is in the MultipleBox_AfterUpdate) if it's true, check to see that the week beginning date has been selected, if that cell is blank - pop up a message - set the box back to unchecked - stop this macro while leaving the form running. Can someone point me back in the right direction? |
All times are GMT +1. The time now is 07:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com