Thread: Help with code
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
John Bundy John Bundy is offline
external usenet poster
 
Posts: 772
Default Help with code

i dont see my answer here so i will post again. You need to make a few
changes that i think will help. It stops the double msgbox issue and lets you
use caps or no caps

Private Sub CommandButton1_Click()
Worksheets("Sheet1").TextBox1.Activate

End Sub
Private Sub TextBox1_Change()
If Len(Worksheets("Sheet1").TextBox1.Text) And
UCase(Left(Worksheets("Sheet1").TextBox1.Text, 1)) < "A" Then
If Len(Worksheets("Sheet1").TextBox1.Text) And
UCase(Left(Worksheets("Sheet1").TextBox1.Text, 1)) < "B" Then
TextBox1.Text = ""
MsgBox "Text Input must begin with either an ""A"" or ""B"", Try Again"
End If
End If
End Sub

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"JMay" wrote:

When I click my cb1 (below) my cursor jumps inside tb1 - FINE OK

Private Sub CommandButton1_Click()
Worksheets("Sheet1").TextBox1.Activate
End Sub

But If I type Mary -- nothing happens << but should get message


Private Sub TextBox1_Change()
If Not Left(Worksheets("Sheet1").TextBox1.Text, 1) = "A" Or
Left(Worksheets("Sheet1").TextBox1.Text, 1) = "B" Then
MsgBox "Text Input must begin with either an ""A"" or ""B"", Try Again"
End If
TextBox1.Text = ""
End Sub