-
Textbox help with msgbox
Ok, I think I am down to my last few problems.
Here is what I would like to do:
If Textbox5 has value then textbox 3 & textbox4 must be empty.
If not, then msgbox " Can only have a value in ....blah blah "
If textbox 3 & textbox 4 have value, then textbox 5 must be empty.
If not, then msgbox " Can only have a value in ....blah blah "
Any ideas??
-
Something like
[vba]
Private Sub TextBox5_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(TextBox5) > 0 Then
If Len(TextBox3) + Len(TextBox4) > 0 Then MsgBox ("3 & 4 should be empty")
Else
If Len(TextBox3) = 0 Or Len(TextBox4) = 0 Then MsgBox ("3 & 4 should not be empty")
End If
End Sub
[/vba]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
Thank you for the code. I am unable to get it to work though. I have posted the workbook as to get a better feeling of what I am trying to accomplish. As well, I have entered this code below to post a critical msgbox. It works well, but is there a way to have it only post the msgbox the one time unless another non-numeric value is put into the textbox? Right now it keeps popping up with the msg even when you hit delete.
[vba]Private Sub TextBox5_Change()
If Not IsNumeric(Me.TextBox5.Value) Then MsgBox "Enter a number only ", vbCritical, "Numbers Only"
With TextBox5
.SelStart = 100
.SelLength = Len(TextBox5)
End With
Range("a22") = TextBox5.Text
End Sub[/vba]
-
I assumed you would complete the data entry in textbox number. Foolish of me I know. Try altering the code to suit the way you use it.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
Forgive my ignorance, but can you please dumb it down a bit more for me.
"I assumed you would complete the data entry in textbox number"
.....what exactly am I supposed to do here....??
-
Looking at post 1, you say you have 3 boxes, 3, 4, 5. You wish to do something to compare the contents. You can only carry out the check after the third is completed. I assumed that was number 5.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules