1

pardon me for my confusing question. Even I don't know how to say it correctly so i'll just illustrate it

Column A          Column B
   A                Mark
   A                
   B                John
   B                Gina
   C               
   C                Kevin
   D                Joy
   D                
   D                Mary

Now, I want to count the number of data on the column B depending on what is on the column A (they are on the same row).

Column C     Column D
  A            1
  B            2
  C            1
  D            2

Thanks!

2 Answers 2

1

In Excel 2007 and later you can use COUNTIFS. Assuming data in A1:B9:

=COUNTIFS($A$1:$A$9,C1,$B$1:$B$9,"<>"& "")

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

I just noticed you asked for VBA, but unless there's some compelling reason, a formula like mine or Ioannis's is preferable.
1

try this (untested as I am not on a PC): =SUMPRODUCT((($A$1:$A$9)=C1)*(($B$1:$B$9)<>""&$A$1000))

Any empty cell in place of $A$1000 will do. This assumes that column C is an input, let me know if else. Place this In cell 'D1' and drag it down. Hope it helps, Sorry if I missed something, cannot test at the moment!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.