PC Review


Reply
Thread Tools Rate Thread

Change Range In COUNTIF Formula Based On Value In A Cell

 
 
Dennis
Guest
Posts: n/a
 
      10th Mar 2011
Hopefully I can make this clear. I have a formula in which I have to
change the range in which I am performing a COUNTIF.

Here's the formula.

=(COUNTIF($J8:$J28,"A"))+(COUNTIF($J8:$J28,"C"))

Essentially what I am doing is copying this formula down the
worksheet. What it is doing is looking at the next 21 line items and
counting how many are equal to A or C. That part works fine and I've
got everything going great.

Problem is, I want to dynamically change the number of line items I
perform the lookup on. Essentially I want to have cell A1 contain a
value that changes the number of rows that I want to look at.

So, if I have the value of 5 in cell A1, I want to change my COUNTIF
range from $J8:$J12.

Can this be done?

Thanks,
Dennis
 
Reply With Quote
 
 
 
 
GS
Guest
Posts: n/a
 
      10th Mar 2011
Dennis explained on 3/10/2011 :
> Hopefully I can make this clear. I have a formula in which I have to
> change the range in which I am performing a COUNTIF.
>
> Here's the formula.
>
> =(COUNTIF($J8:$J28,"A"))+(COUNTIF($J8:$J28,"C"))
>
> Essentially what I am doing is copying this formula down the
> worksheet. What it is doing is looking at the next 21 line items and
> counting how many are equal to A or C. That part works fine and I've
> got everything going great.
>
> Problem is, I want to dynamically change the number of line items I
> perform the lookup on. Essentially I want to have cell A1 contain a
> value that changes the number of rows that I want to look at.
>
> So, if I have the value of 5 in cell A1, I want to change my COUNTIF
> range from $J8:$J12.
>
> Can this be done?
>
> Thanks,
> Dennis



=(COUNTIF(J8:OFFSET($J8,$A$1-1,0),"A")+(COUNTIF($J8:OFFSET($J8,$A$1-1,0),"C")))

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change 3rd cell colour based on cell 1 >= cell2 in range wombarrapete Microsoft Excel Discussion 8 21st Dec 2008 09:41 PM
Change range based on value of a cell kwaldman@gmail.com Microsoft Excel Discussion 4 19th Mar 2008 12:51 PM
Add Cell range based on color of cell to existing formula =?Utf-8?B?SnVsIGluIE9oaW8=?= Microsoft Excel Programming 2 30th Jul 2007 02:18 PM
How do I change cell color based upon data range within the cell? =?Utf-8?B?Q2hyaXMgU2FuZGVycw==?= Microsoft Excel Worksheet Functions 1 6th Mar 2006 08:59 PM
Formula based on one cell, pased in another range =?Utf-8?B?Q2Fycmll?= Microsoft Excel Programming 1 1st May 2004 03:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:48 AM.