Find and Count Instances

madhuchelliah

Board Regular
Joined
Nov 22, 2017
Messages
226
Office Version
  1. 2019
Platform
  1. Windows
Hello Folks, I want to check the instances of the cells in C column of sheet1 in sheet2. In the D column i want how many instances it is there in the sheet2. For example if i have 200 value in c column in sheet1 the macro should check sheet2 for 200 and return with how many instances it is there in sheet2. Note: i have lot of values in C column.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Which column of Sheet2 should be searched to find the values in Sheet1 column C?

M.
 
Upvote 0
Say your data are Sheet2 columns A:Z (adjust to suit)
=COUNTIF(Sheet2!A:Z,C2)

M.
 
Upvote 0
Maybe this UDF (User Defined Function)

Code:
Function CountSh2(v As Variant)
    CountSh2 = Application.CountIf(Sheets("Sheet2").UsedRange, v)
End Function

In Excel
D2
=CountSh2(C2)

M.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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
Back
Top