ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   end sub in If then macor (https://www.excelbanter.com/excel-programming/277609-end-sub-if-then-macor.html)

P. Blaauw

end sub in If then macor
 
If I want to end the sub routine "Private Sub
UserForm_Initialize()" in a if then command, what will be
the command for that. I tried end Sub and Exit Sub but
that doesn't seem to work


2smart

end sub in If then macor
 
If a = 1 GoTo Macro_End

Macro_End:
End Sub

"P. Blaauw" wrote in message
...
If I want to end the sub routine "Private Sub
UserForm_Initialize()" in a if then command, what will be
the command for that. I tried end Sub and Exit Sub but
that doesn't seem to work




Ron de Bruin

end sub in If then macor
 
Try this example that don't run the code if cell A1 have a value of 1

Private Sub UserForm_Initialize()
If Sheets("sheet1").Range("a1").Value = 1 Then Exit Sub
MsgBox "hi"
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"P. Blaauw" wrote in message ...
If I want to end the sub routine "Private Sub
UserForm_Initialize()" in a if then command, what will be
the command for that. I tried end Sub and Exit Sub but
that doesn't seem to work




Jean-Paul Viel

end sub in If then macor
 
Hi,



It seems that you don't wand the form to show. If it's the case, exit sub
will jus get you out of the initialize procedure and keep display the form.
As the name said, it is use to give initial values to something. To remove
the form, use a code like that:



If MsgBox("ok", vbYesNo) = vbYes Then Unload Me



And in the procedure that display the form, trap the error because it will
try to display some thing that is not in memory.



On Error Resume Next

UserForm1.Show




--
JP

http://www.solutionsvba.com


"P. Blaauw" wrote in message
...
If I want to end the sub routine "Private Sub
UserForm_Initialize()" in a if then command, what will be
the command for that. I tried end Sub and Exit Sub but
that doesn't seem to work





All times are GMT +1. The time now is 06:02 AM.

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