VBA – Loop Through All Textboxes in a Form – Excel Macro
This VBA code will loop though all textboxes in your userform that are following the naming convention textBox[x] (ex. textBox1, textBox2, textBox3 ….. textBox255)
|
1 2 3 4 5 6 7 8 9 10 |
For Each txtboxitem In Me.Controls If Left(txtboxitem.Name, 6) = "textBox" Then If txtboxitem.Text <> "" Then 'do something Exit For End If End If Next txtboxitem |
Posted by Excel Instructor:
http://www.houstoncomputerclasses.com/excel-classes/
