Taquitoburrito
Taquitoburrito

Reputation: 57

How do I count how many times a specific value shows up in excel?

I'm searching for "***" in the A column, I need to know how many times it appears so that I can loop my code that many times. I can't seem to find out how to do it. Thanks for the help!

Upvotes: 0

Views: 1125

Answers (2)

Cohan
Cohan

Reputation: 4544

If your cells just have "***" in them and it's not anything else, you can invoke the worksheet function CountIF

Application.WorksheetFunction.CountIf(ActiveSheet.Range("A:A"), "~*"&"~*"&"~*")

Edited per TMH8885's comment and the asterisk being a wildcard. The tilde does seem to work.

Upvotes: 2

cr1msonB1ade
cr1msonB1ade

Reputation: 1716

How about this function within excel: https://support.microsoft.com/en-us/kb/214153

It shows the function: =COUNTIF(range,"text") which you can use as =COUNTIF(A:A,"***")

UPDATE Actually need to escape wildcards so it would be: =COUNTIF(A:A,"~*~*~*")

It counts the number of matched to your pattern "***" in column A.

Upvotes: 1

Related Questions