• 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.

Count If in textbox VBA

fher9728

New Member
Hi,
I am doing a form where I have 8 textboxs named ddc, example: ddc1, ddc1...ddcn.
then I have another textbox name quantcoup, that is the textbox I want to receive the count if of everyone of the ddcs that have text in it throughout a command button. Also, I want that the count if detect it as text, but the vba code I used is not working for me, the code is the next:

Code:
Private Sub CommandButton2_Click()


On Error Resume Next
    quantcoup.Text = Abs((ddc1.Value = "*") + (ddc2.Value = "*") + (ddc3.Value = "*")+ (ddc4.Value = "*")+ (ddc5.Value = "*")+ (ddc6.Value = "*")+ (ddc7.Value = "*")+ (ddc8.Value = "*"))
   
    End Sub
I´m new at vba and Ive been doing research in the internet but I can´t get a working method for this, if anyone could help it would be great.
Thanks
 

prasaddn

Active Member
try this.... i have given the code for two text boxes.. you can keep adding as many as you need.

Code:
Private Sub CommandButton2_Click()

On Error Resume Next
    quantcoup.Text = Abs(Not VBA.IsEmpty(ddc1.Value) And Not IsNumeric(ddc1.Value))  +  Abs(Not VBA.IsEmpty(ddc2.Value) And Not IsNumeric(ddc2.Value))
    End Sub
 
Last edited by a moderator:
Top