UserForm_Initialize, how to exit sub based on condition?
Private Sub UserForm_Initialize()
'other code removed
If Left(ActiveWorkbook.Name, 12) = "Template DIP" Then
MsgBox "Please do not edit This file! Use ""Save as"" prior to editing!"
Unload Me
End If
End Sub
--
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my addy)
"Rick S." wrote in message
...
IO hope I can explain this, I have a userform that will open on a button
click from a worksheet. First thing I am doing is testing the file name
to
ensure the user won't overwrite the master file.
I can do that easily enough, the trouble I have is if the condition is
true
(they are using the master file) I prompt with a msgbox and then wish to
exit
the sub but the userform loads anyhow.
'=======
Private Sub UserForm_Initialize()
'other code removed
If Left(ActiveWorkbook.Name, 12) = "Template DIP" Then
MsgBox "Please do not edit This file! Use ""Save as"" prior to editing!"
End If
End Sub
'=======
No matter what I try I can not stop the userform from loading if the above
condition is true.
--
Regards
VBA.Noob.Confused
XP Pro
Office 2007
|