Countif Valve is in Several Different Locations

Timberwolf

New Member
Joined
Feb 20, 2018
Messages
26
Hi all

What I'm looking to do is on Sheet3 cell C2 I want a formula to check six different rows on Sheet1 to see if they match cell A2 on Sheet3 and each time it matches add 1.

I have the code looking in one row as follows =COUNTIF(Sheet1!J:J,[@[Item '#]]) but I also want it to check SHEET1 rows L:L N:N P:P R:R and T:T

I don't want them all to match, I want it to count 1 if any of them match

So if Sheet1 cell J2, L2, N2, and P2 match [Item '#] there would be 4 in cell C2 on Sheet3 or if it was only in L2, N2, and P2 it would have a value of 3.

I hope someone can understand this and help me out, I know I may not be explaing myself properly.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi,

If you can't group the Columns (not rows) together like J:T because of other data in between that might throw off your count, then use SUM to add up the counts, like:

=SUM(COUNTIF(Sheet1!J:J,[@[Item '#]]),COUNTIF(Sheet1!L:L,[@[Item '#]]),COUNTIF(Sheet1!N:N,[@[Item '#]]),COUNTIF(Sheet1!P:P,[@[Item '#]]),COUNTIF(Sheet1!R:R,[@[Item '#]]),=COUNTIF(Sheet1!T:T,[@[Item '#]]))

Also, try not to use Entire Column references whenever possible, maybe use a range that you know is larger than the data will ever be, like J1:J10000
 
Upvote 0
Thank you So much that worked great (small edit to the last countif code. had to delete the "=" sign) Just curious why I should not use the entire Column reference?
 
Upvote 0
You're welcome, and oh yeah, missed deleting that last = sign, I copied and pasted your COUNTIF formula 6 times, then updated the Column references.

About the entire column reference, that's because there are over a Million rows in Each column, so it's Always good practice to not use entire column references as it will slow down calculations.
 
Last edited:
Upvote 0
OK, new problem how do I copy the code down without the numbers changing EG C2 says L2:L10000, C3 says L3:L10001, C4 says L4:10002.

Sorry I'm sure that is basic Excel but I'm new to the programming part. Boss said can you make me a table that does this and this and this? Sure can! lol and off to Professor Google I went lol.
 
Upvote 0
Use the $ to lock Column and/or Cell references, in this case, like this: L$1:L$10000
 
Upvote 0
You're very welcome, post again whenever you need help.
 
Upvote 0

Forum statistics

Threads
1,216,038
Messages
6,128,450
Members
449,453
Latest member
jayeshw

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