Zygoid
Programmer
- Nov 15, 2007
- 5
what I am trying to do is
if textbox15 = "" then run some code and exit sub
or
if textbox15 <> "" then run some code and exit sub
what is happening is
if textbox15 = "" then runs some code (not exiting sub)and then runs if textbox15 <> "" then runs the some code.
problem comes because when "manual" is placed in textbox15 then runs the second if statement. I cannot seem to get it to not run the second if statement once "manual" is placed in textbox15.
anyone have an idea?
if textbox15 = "" then run some code and exit sub
or
if textbox15 <> "" then run some code and exit sub
what is happening is
if textbox15 = "" then runs some code (not exiting sub)and then runs if textbox15 <> "" then runs the some code.
problem comes because when "manual" is placed in textbox15 then runs the second if statement. I cannot seem to get it to not run the second if statement once "manual" is placed in textbox15.
anyone have an idea?
Code:
Private Sub TextBox15_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Rng As Range
With TextBox15
If .Value = "" Then
TextBox15.Value = "Manual"
TextBox1.Value = Format$(Date, "m/d/yyyy")
userform3.Show
Exit Sub
End If
If .Value <> "" Then
Set Rng = ActiveWorkbook.Sheets("database").Columns(9).Find(TextBox15.Value)
If Not Rng Is Nothing Then
If MsgBox("text for message1") = vbOK Then
Cancel = True
End If
With TextBox15
.SelStart = 0
.SelLength = Len(.Value)
.SetFocus
End With
Exit Sub
ElseIf Rng Is Nothing Then
If MsgBox("text for message2") = vbNo Then
Cancel = True
With TextBox15
.SelStart = 0
.SelLength = Len(.Value)
.SetFocus
End With
Exit Sub
ElseIf vbYes Then
TextBox15.Value = "Manual"
TextBox1.Value = Format$(Date, "m/d/yyyy")
userform3.Show
Exit Sub
End If
End If
End If
End With
End Sub