Text box formatting

G

Greg B

I have a userform where the person puts in totals

How do I get excel to not allow a total more than 180 in a textbox.

Also is there a chance of excel giving a warning about this total

Thanks in advance

Greg
 
R

Rob Bovey

Greg B said:
I have a userform where the person puts in totals
How do I get excel to not allow a total more than 180 in a textbox.
Also is there a chance of excel giving a warning about this total

Hi Greg,

Here's one very simplified way to accomplish this:

Private Sub TextBox1_Change()
If Val(TextBox1.Text) > 180 Then
MsgBox "180 is the maximum allowed."
TextBox1.Text = ""
End If
End Sub

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top