Counting TextBox values

  • Thread starter Thread starter Patrick C. Simonds
  • Start date Start date
P

Patrick C. Simonds

I have a multipage UserForm. On page 2 are 3 TextBoxes (201, 205 and 209).
Each of these TextBoxes can have any one of 5 values (Yes, No, No Contact,
No Phone or Not Called. On page 1 I want to add a Textbox which tells me
how many of the TextBoxes had the value "No Contact"
 
Something like this may work for you - Palce behind the useform.
:

Sub CountNoContact()

Dim mycount As Integer
Dim ctl As Control
mycount = 0

For Each ctl In Me.Controls

If TypeName(ctl) = "TextBox" Then

If UCase(ctl.Text) = "NO CONTACT" Then

mycount = mycount + 1

End If

End If

Next

Me.TextBox1.Text = mycount

End Sub
 
Back
Top