not run macro on first instance

M

MervB

Word 2003 or XP - I have a tickbox in a userform which has a multi action
macro that runs on entry. Being the first userform control it automatically
fires when the form is openned. It is important that this be the first
control in the Tab sequence - how can I stop this macro from running on the
first instance?

Thanks
MervB
:)
 
T

Tony Jollans

You could set a flag in Userform Initialize and then check it in your
checkbox entry ...

Dim FirstTimeFlag As Boolean

Private Sub UserForm_Initialize()
FirstTimeFlag = True
End Sub

Private Sub CheckBox1_Enter()
If FirstTimeFlag Then
FirstTimeFlag = False
Exit Sub
End If

' rest of your code

End Sub
 
M

MervB

Thanks Tony - sometimes the obvious kicks you in yhr eye and you still can't
see it!

I believe your spot on thanks again.

MervB
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top