textbox max of 2 and min of 1

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
16,692
Maybe this for an active-x textbox named "Textbox1".
Code:
Private Sub TextBox1_Change()
If Not TextBox1.Text = "1" And Not TextBox1.Text = "2" And Not TextBox1.Text = "" Then
    MsgBox "Only text permitted is a 1 or a 2 - try again"
    TextBox1.Text = ""
    Exit Sub
End If
End Sub
 

Forum statistics

Threads
1,089,270
Messages
5,407,303
Members
403,132
Latest member
Black_Mamba_1666

This Week's Hot Topics

Top