count common cell entries within 2 ranges

jammoca

Banned
Joined
Nov 6, 2002
Messages
1,100
I have dates within range F7:BB7.

I have another range that also have dates as entries ... BW10:DO10

I'd like to have a formula that couns how many cells within those 2 ranges share a common date entry.

I'm assuming it will be a countif formula, but can't seem to figure it through.

Kind regards

Chris
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

mirabeau

Banned user
Joined
Nov 4, 2010
Messages
2,075
I have dates within range F7:BB7.

I have another range that also have dates as entries ... BW10:DO10

I'd like to have a formula that couns how many cells within those 2 ranges share a common date entry.

I'm assuming it will be a countif formula, but can't seem to figure it through.

Kind regards

Chris
Chris,

Not a formula as you requested, but, if only for interest
Code:
Sub in_common()
Dim b(50000) As Byte
Dim rng1, rng2, c, k As Long

rng1 = Range("F7:BB7")
rng2 = Range("BW10:DO10")

For Each c In rng1
    If Len(c) > 0 Then b(c) = 1
Next c

For Each c In rng2
    If b(c) = 1 Then b(c) = 2
Next c

For Each c In rng1
    If b(c) = 2 Then k = k + 1
Next c

MsgBox k & " dates in common"

End Sub
Also, to clarify.
If you have 2 dates the same in the first range and one date equal to these in the second range, do you count this as 3 cells sharing the same date, or only 2?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,862
Messages
5,834,037
Members
430,256
Latest member
Todor T

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top