Originally Posted by
jnmturner
Hi Richard,
Thanks for your response. To explain a little better:
I have a month/year cell on Sheet 1 which is updated manually each month. Also on Sheet 1 I have a list of columns, with data, for a range of months up to 2009. I need to extend the range in the COUNTIF statement each month to the column that corresonds to the month/year. Instead of changing each of the 50 cells manually I am looking to get a way of automating it once the month/year cell is updated.
e.g.
COUNTIF(‘SHEET 1’!$A$1:$W$99,”X”) Feb 2008 Report
COUNTIF(‘SHEET 1’!$A$1:$X$99,”X”) Mar 2008 Report
COUNTIF(‘SHEET 1’!$A$1:$Y$99,”X”) Apr 2008 Report
this has to be done for 50 cells each of which has a different range (on Sheet 2).
Hope this makes sense.
Hi,
I'm not quite clear where your 50 columns comes in if you're only projecting through to 2009, but I'll have a stab. This problem resolves itself when we can convert the current month and year into a 'Period' number, and then convert this period number into a column letter reference, which we can then use in an INDIRECT() function.
So first the period.
Instead of the Month/Year cell, or as well as if you need this for some other purpose, have a cell where you enter the first day of the month in question. i.e. a 'proper' XL date number. In the case of say February enter 1/2/08 (That's a standard UK presentation - I guess if you're in the US you do it the wrong way and express it as 2/1/08 ) Put this in say A1
Now in another cell which you name 'Period' enter the following formula:
This will repesent a column offset depending which month you're dealing with. For instance Feb 2008 returns 2, and Feb 2009 returns 14.
Now you can change your COUNTIF() function to include an INDIRECT() function which uses this period number :
Obviously this is based on column W (col 23) being February 2008 and the first of your columns of data. i.e. the period number plus 21. Obviously adjust this if things change.
HTH
Bookmarks