ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Text box formatting (https://www.excelbanter.com/excel-worksheet-functions/18367-text-box-formatting.html)

Greg B

Text box formatting
 
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




Rob Bovey

"Greg B" wrote in message
...
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




All times are GMT +1. The time now is 04:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com