View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mats Samson Mats Samson is offline
external usenet poster
 
Posts: 112
Default Checking characters

Thank you Jakob,
it worked fine!
Cheers
Mats

"Jacob Skaria" wrote:

Try this Textbox1 Exit event...code...You can add more invalid characters to
the variable strInvalid...

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim strInvalid As String, intTemp As Integer
strInvalid = "%&/."
For intTemp = 1 To Len(strInvalid)
If InStr(Me.TextBox1.Text, Mid(strInvalid, intTemp, 1)) 0 Then
MsgBox "Invalid character present " & strInvalid
Cancel = True
End If
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Mats Samson" wrote:

RI've a Userform where a textbox picks its value as a proposal from a
worksheet cell when initiating.
This cell may contain invalid filename characters like %&/.
I want the user alerted so they may change the characters in the textbox
before proceeding. The corrected textbox string will be saved in another cell.
regards
Mats