Declare a collection with global scope. It will contain all of the controls handled by the same procedure.
Create a class module to process the event of interest. Here's one for textboxes that must contain numeric strings for positive whole numbers:
Option Explicit
' Constrains member textboxes to have non-negative whole number values only
Public WithEvents clsTxtNum As MSForms.TextBox
Public Property Set Control(txtNumNew As MSForms.TextBox)
Set clsTxtNum = txtNumNew
End Property
Private Sub clsTxtNum_Change()
Dim sVal As String
Dim bCodeChange As Boolean
If bCodeChange Then Exit Sub
If gbCodeChange Then Exit Sub
sVal = clsTxtNum.Value
If Len(sVal) = 0 Then GoTo Just0
If Not IsNumeric(sVal) Then GoTo BadInp
If Int(CDbl(sVal)) <> CDbl(sVal) Then GoTo BadInp
wksQuo.Range(clsTxtNum.Name) = clsTxtNum.Value
EnableControls
SetLabels
OuttaHere:
bCodeChange = False
Exit Sub
BadInp:
MsgBox Prompt:="Whole number numeric values only!", _
Title:=gsTitle
Just0:
bCodeChange = True
clsTxtNum.Value = "0"
GoTo OuttaHere
End Sub
When the form initializes, create a class instance for each relevant textbox and add it to the collection.
Select Case TypeName(ctl)
Case "CheckBox"
Set clsChk = New clsEventSinkChk
Set clsChk.Control = ctl
gcolCtl.Add Item:=clsChk
Case "OptionButton"
Set clsOpt = New clsEventSinkOpt
Set clsOpt.Control = ctl
gcolCtl.Add Item:=clsOpt
Case "TextBox"
If LCase(ctl.Name) Like "txtnum*" Then
Set clsTxtNum = New clsEventSinkTxtNum
Set clsTxtNum.Control = ctl
gcolCtl.Add Item:=clsTxtNum
Else
Set clsTxt = New clsEventSinkTxt
Set clsTxt.Control = ctl
gcolCtl.Add Item:=clsTxt
End If
Bookmarks