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)

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.chicagocomputerclasses.com/excel-classes/