View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rachel Rachel is offline
external usenet poster
 
Posts: 113
Default Check box to change the format of a text box

Hi John,
Sorry for the late response - I actually couldn't find my question after
posting it!!
Your codes worked perfectly, thank you so much!!

"john" wrote:

Rachel,

place both these procedures behind your form & see if it does what you want.
the Exit routine ensures format is applied after user has updated entry.

Hope helpful

Private Sub chkmobile_Click()

With Me.txtphone

.Text = Replace(Replace(.Text, " ", ""), "-", "")

If Me.chkmobile.Value = True Then

.Text = Format(.Text, "0000-000-000")

Else

.Text = Format(.Text, "00-0000-0000")

End If

End With

End Sub

Private Sub txtphone_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call chkmobile_Click
End Sub
--
jb


"Rachel" wrote:

I have a text box (txtphone) in a user form that a user will enter a phone
number into. The default format of this text box is to be "00-0000-0000". I
want them to be able to tick a check box (chkmobile) if the number is a
mobile number and the format of txtphone is to change to "0000-000-000". If
they then untick chkmobile the format returns to "00-0000-0000". Is this
possible?

Thanks :)