• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Countif statement using a cell reference to define the range

achrist3

New Member
Hi Chandoo. First time poster, long time referencer. Your site is a great reesource. I have a quick question for you. How do I use a cell reference to define the range in a countif statement? So a typical countif statement would read something like this =countif('sheet1'!$Q$3:$S$14999,b3) where Q3 through S14999 define the range and b3 is the criteria. What I would like to do is define the range by using other cells within the workbook. For example, cell A1 in the workbook would define the row # to start the range (this cell would change based on some other calculations). In thsi example, say cell A1 had a value of 7142. What I would like the formula to do is recognize cell A1 as the starting row position. In this case, the example formula I illustrated above would now appear as follows: =countif('sheet1'!$Q$7142:$S14999,b3). My attempts to do this thus far have returned a 0 or #REF!. Help with a solution is greatly appreciated. Cheers!
 
Hello achrist3.............welcome to the forum...

You can use


=countif(indirect(address(sheet1!A1,17,3)):$S14999,b5)


in the above 17 represents the column Q and A1 has the row value, you can change the absolute to relative by changing the no 3 in address.
 
Indian - Thank you. Almost there. How do I write into the formula that the range is on another tab from where the formula exists. For example, I want to use a cell, cell A1 on sheet1 to adjust the range but the range I want it to look at is on sheet2. the formula written out (and incorrectly( would look like this. =countif(sheet2$Q$A1,$S$14999,b3. Where A1 is equal to a cell and reference number sheet1. Now do write this one? Thanks again. I really appreciate your time and help on this.


Cheers!
 
I think this will do it:

=COUNTIF(INDIRECT("'Sheet2'!"&ADDRESS(Sheet1!A1,17,3)&":S14999"),B3)
 
Back
Top