What is your Favourite Excel VBA Class that you frequently use
CTextbox class is used to only allow input of numbers in userform text boxes.. Very useful
Class Module name CTextbox
Code
Option Explicit Public WithEvents TBox As MSForms.TextBox
Private Sub Tbox_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = CheckInput(KeyAscii)
End Sub
Public Function CheckInput(ByVal KeyAscii As MSForms.ReturnInteger)
CheckInput = IIf((KeyAscii >= 48) And (KeyAscii <= 57), KeyAscii, vbKeyClear)
End Function
Userform code
Code
Option Explicit
Dim TextBoxes() As New CTextbox
Private Sub UserForm_Initialize()
Dim ctl As MSForms.Control
Dim idx As Long
For Each ctl In Me.Controls
If TypeOf ctl Is MSForms.TextBox Then
ReDim Preserve TextBoxes(idx)
Set TextBoxes(idx).TBox = ctl
idx = idx + 1
End If
Next ctl
End Sub
Display More
Please add your favourite and most frequently use class