Counting TextBox values

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"
 
J

john

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top