• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Counting Textbox value using CountIf - Excel VBA

Prima Satria

New Member
Hi,

I have 3 textboxes in number format. In texbox1 value = 11, textbox2 value = 5 and textbox 3 value = 11.
And I want to count how many number of 11 in a textbox4, every time the value in textbox1 is change or update.

Code:
Private Sub TextBox1_AfterUpdate()
    On Error Resume Next
    TextBox4.Value = Application.CountIf(TextBox1.Value, 11) + Application.CountIf(TextBox2.Value, 11) +Application.CountIf(TextBox3.Value, 11)
End Sub
Thanks in advance
 

Hui

Excel Ninja
Staff member
Code:
Private Sub TextBox1_Enter()
On Error Resume Next
    TextBox4 = Abs((TextBox1.Value = 11) + (TextBox2.Value = 11) + (TextBox3.Value = 11))
End Sub
 

Prima Satria

New Member
Code:
Private Sub TextBox1_Enter()
On Error Resume Next
    TextBox4 = Abs((TextBox1.Value = 11) + (TextBox2.Value = 11) + (TextBox3.Value = 11))
End Sub
Dear Hui,

Thanks for the response, by the way what is the meaning of Abs statement?

Best Regards
 
Top