less than 1 minute read
Snippets to loop through control types or a specific control type. Especially useful for bulk actions.
Control Type Names
- Label
- TextBox
- ComboBox
- ListBox
- CheckBox
- OptionButton
- ToggleButton
- Frame
- CommandButton
- TabStrip
- MultiPage
- ScrollBar
- SpinButton
- Image
Loop through all controls
Sub LoopAllControls() '// Vars Dim ctrl As Control '// Loop Through each control on UserForm For Each ctrl In UserForm1.Controls '// Do something with that control type...eg make visible ctrl.Visible = TRUE Next ctrl
End Sub
Loop through a specific control type
Sub LoopSpecificControl() '// Vars Dim ctrl As Control Dim ctrlType As String '// Choose control type to loop through ctrlType = "Textbox" '// Loop Through each control on UserForm For Each ctrl In UserForm1.Controls '// Test specific control type If TypeName(ctrl) = ctrlType Then '// Do Something With That Control Type...eg no value ctrl.Value = "" End If Next ctrl
End Sub
Tags: userform
Categories: vba
Updated: March 19, 2017
1 minute read
Here’s the simple steps to highlight the row and column of the selected cell which can be extremely useful when navigating large sets of data. Here’s a littl…
less than 1 minute read
How it Works Using SEARCH and ISNUMBER When you need to check if a cell contains specific text (or string) we need to combing the SEARCH and ISNUMBER functio…
less than 1 minute read
So you have a 0% value on one of your data labels and want to hide it?
1 minute read
Download the example workbook here: calculate-time-between-dates.xlsx