Thread: Phone numbers
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Phone numbers

just a guess, but add a line of code such as this as your first line of code
finish button:

Private Sub CommandButton1_Click()
Me.TextBox1.SetFocus
'then the rest of the code
end sub
--


Gary


"Patrick C. Simonds" wrote in message
...
I found the code below on-line (writen by Dick Kusleika) which works fine if I
click on another TextBox but if I click on my Finished Button the code does not
run. Any ideas what can be done to solve this proble?

Private Sub TextBox7_Exit(ByVal Cancel As MSForms.ReturnBoolean)

PhoneNum = Me.TextBox7.Text
If Len(PhoneNum) = 7 Then
FormatNum = "(360) " & Left(PhoneNum, 3) & "-" & Right(PhoneNum, 4)
ElseIf Len(PhoneNum) = 10 Then
FormatNum = "(" & Left(PhoneNum, 3) & ") " & Mid(PhoneNum, 4, 3) & _
"-" & Right(PhoneNum, 4)
Else
MsgBox "Not a Valid Phone Number"
Cancel = True
End If
Me.TextBox7.Text = FormatNum

End Sub