Countif Cell equals Active Worsheet

tcnt9176

Board Regular
Joined
Jun 23, 2008
Messages
223
Hello. I need to enter a countif formula if a cell equals the name of the active worksheet and also cell A1. My worksheets are not always the same and I also want to be able to copy this formula to multiple worksheets so if the formula states active worksheet then is should work properly when I past it to multiple tabs (at least in my head).
Thanks. Chris
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I assume that the criteria is a truncation of sheetname and the value in A1.

Assuming that your countif range is A2:A100

=COUNTIF($A$2:$A$100,RIGHT(CELL("filename"),LEN(CELL("filename"))-SEARCH("]",CELL("filename"),1))&$A$1)
 
Upvote 0
You will have to forgive me. I am still very limited in my knowledge of VBA and I am trying to make this work in my head. I probably did not explain it the best either. I need to count any line if it matches A1 & if E1 equals the name of the active sheet. Column E is YYYY-MM and I have multiple tabs with different months. I was doing a little searching and put together the following but of course it didn't work.

=SUMPRODUCT(--('Placement Detail'!C:C=A3),--('Placement Detail'!E:E=ActiveSheet.Name))
 
Upvote 0
Try:

=SUMPRODUCT(--('Placement Detail'!C1:C1000=A1),--('Placement Detail'!E1:E1000=RIGHT(CELL("filename"),LEN(CELL("filename"))-SEARCH("]",CELL("filename"),1))))
 
Last edited:
Upvote 0
AWESOME!!! Exactly what i needed. How should this formula be altered to get the sum of these same lines? Thank you very much!!!
Chris
 
Upvote 0
AWESOME!!! Exactly what i needed. How should this formula be altered to get the sum of these same lines? Thank you very much!!!
Chris

=SUMPRODUCT(--('Placement Detail'!C1:C1000),--('Placement Detail'!C1:C1000=A1),--('Placement Detail'!E1:E1000=RIGHT(CELL("filename"),LEN(CELL("filename"))-SEARCH("]",CELL("filename"),1))))
 
Upvote 0
I'm sorry. I should have told you that the $$ that need to be summed are in column F. How do I have it add up column F when it meets the conditions of the formula above? This should be my last question :) Thanks!!!
 
Upvote 0
I'm sorry. I should have told you that the $$ that need to be summed are in column F. How do I have it add up column F when it meets the conditions of the formula above? This should be my last question :) Thanks!!!

=SUMPRODUCT(('Placement Detail'!F1:F1000),--('Placement Detail'!C1:C1000=A1),--('Placement Detail'!E1:E1000=RIGHT(CELL("filename"),LEN(CELL("filename"))-SEARCH("]",CELL("filename"),1))))
 
Upvote 0
It worked perfectly!!! Thanks again for your help!!! One of these days I would like to take a course on this stuff. Any suggestions? This way I don't have to bother you & others on here.
 
Upvote 0
Ok. I am now working in a different area of the spreadsheet and I was trying to use the format above and I cannot get the formula to work. Can someone tell me what is wrong with the formula?

ActiveCell.FormulaR1C1 = _
"=SUMPRODUCT((--('Placement Detail'!C[10]=RC[-1]),--('Placement Detail'!C=9999)) + SUMPRODUCT(--('Placement Detail'!C[10]=RC[-1]),--('Placement Detail'!C=9000)) _
--('Placement Detail'!R[-2]C[2]:R[9997]C[2]=RIGHT(CELL(""filename""),LEN(CELL(""filename""))-SEARCH(""]"",CELL(""filename""),1)))))"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,397
Members
449,081
Latest member
JAMES KECULAH

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