Put Sheet Name as a Variable in Count or CountIf?

kreber

Board Regular
Joined
Jan 5, 2007
Messages
73
Hello Everyone,
In a particular sheet, I am trying to see how many items there are in a different sheet for a particular month.

Currently I am using the following formula in each month's column:
=COUNT('SDG 2010'!I1:I1328) - (COUNTIF('SDG 2010'!I1:I1328, "<12/1/2010") + COUNTIF('SDG 2010'!I1:I1328,">12/31/2010"))

Obviously, the dates are different depending on for which month I am counting items. The above example would be for December (read it as "count everything, and subtract from that anything less than December 2010 plus anything greater than December 2010) = # of items dated in December 2010.

Even though my logic may not be the most efficient, my real issue is:
SDG 2010 is a sheetname with a space in it. I would like to be able to manually change the sheet's name in its tab to SDG 2011, SDG 2012, etc, each year, without having to update the long cell formula above for each month! I've tried using INDIRECT in various ways to no avail, but maybe your way will work, who knows?

Thanks all,
Kurt
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
You can try using INDIRECT in the COUNT functions, like this
Excel Workbook
CD
1Sheet22
Sheet3
Excel 2007
Cell Formulas
RangeFormula
D1=COUNTA(INDIRECT(C1&"!A1:A2"))
 
Upvote 0
To get the sheetname, a non VBA solution would be:

=RIGHT(CELL("filename"),LEN(CELL("filename"))-FIND("]",CELL("filename")))

Use that with the function INDIRECT (which you I assume you already know) and you will get your desired result.
 
Upvote 0

Forum statistics

Threads
1,225,281
Messages
6,184,037
Members
453,206
Latest member
Atko

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