Input mask for userform textbox

  • Thread starter Thread starter Axehandler
  • Start date Start date
A

Axehandler

I am tying to set up an input mask for a textbox in a userfrom.

The user will only be able to enter a 12 character string.
The string will look like GSSL########
All entries into this box must have GSSL at the beginning,
and the ######## represents any 8 digit number.

Is this even possible in Excel.

I have been trying to crack this for some time.

I am extremly new to VBA and i could be missing something simple.

Any help appriciated.
Axe.
 
Hi

personally i would create a text box that required the user to only enter
the 8 digits, then on exit of the text box i would check the length and
whether or not it is a number, then i would append the GSSL bit myself
e.g.

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim snum As String
If Len(TextBox1.Value) <> 8 Or
Application.WorksheetFunction.IsNumber(Val(TextBox1.Value)) = False Then
MsgBox "Please ensure that number you enter has eight digits"
End If
snum = "GSSL" & TextBox1.Value
End Sub

Cheers
JulieD
 
Back
Top