GuillaumeJ
New Member
- Joined
- Mar 10, 2004
- Messages
- 27
hi everyone,
I want to create a short macro to count the number of cells in a column, based on a condition.
All the cells contains either "yes" or "no", and the options of counting are the number of yes, the number of no and all of them
Let's say I have all my values in the range A1:A100, my condition is registered in cell B1, knowing that the value can be "Yes", "No", "All"
My code is the following:
For i = 1 to 100
If range("A" &i).Value = Range("B1").value Then
count = count +1
Else
count = count
End if
Next i
Is there a way to put in the Range("B1").Value a kind of wildcard when the condition "All" is selected so then only my condition in B1 will change and not the macro itself ?
It may look a bit complex, but I want to count items with various conditions located in several cells, so I will keep this "If" adding conditions on anothers cells.
Any help will be great !
guillaume
I want to create a short macro to count the number of cells in a column, based on a condition.
All the cells contains either "yes" or "no", and the options of counting are the number of yes, the number of no and all of them
Let's say I have all my values in the range A1:A100, my condition is registered in cell B1, knowing that the value can be "Yes", "No", "All"
My code is the following:
For i = 1 to 100
If range("A" &i).Value = Range("B1").value Then
count = count +1
Else
count = count
End if
Next i
Is there a way to put in the Range("B1").Value a kind of wildcard when the condition "All" is selected so then only my condition in B1 will change and not the macro itself ?
It may look a bit complex, but I want to count items with various conditions located in several cells, so I will keep this "If" adding conditions on anothers cells.
Any help will be great !
guillaume