# Referencing a range of columns and rows with the IF function

1. ## Referencing a range of columns and rows with the IF function

I am trying to use the following IF function to search a range of cells to
find the number 1 and then return either 1 or leave the cell blank. However,
it does not look at the range of cells.

A4=IF(A1:AS3=1),1,""

Any sugestions would help.
--
Cliff  Register To Reply

2. ## Re: Referencing a range of columns and rows with the IF function

=IF(COUNTIF(A1:AS3,1)>0,1,"")

--

Regards,

Peo Sjoblom

Northwest Excel Solutions

www.nwexcelsolutions.com

Portland, Oregon

"Cliff" <Cliff@discussions.microsoft.com> wrote in message
news:807BEF21-8669-4288-A5E6-60467FBF2DEF@microsoft.com...
>I am trying to use the following IF function to search a range of cells to
> find the number 1 and then return either 1 or leave the cell blank.
> However,
> it does not look at the range of cells.
>
> A4=IF(A1:AS3=1),1,""
>
> Any sugestions would help.
> --
> Cliff  Register To Reply

3. If you want to return 1 if 1 occurs anywhere in that range

=IF(COUNTIF(A1:AS3,1),1,"")  Register To Reply

4. ## Re: Referencing a range of columns and rows with the IF function

Thanks, but what does the ,1 after the range A1:AS3 stand for?
--
Cliff

>
> If you want to return 1 if 1 occurs anywhere in that range
>
> =IF(COUNTIF(A1:AS3,1),1,"")
>
>
> --
> ------------------------------------------------------------------------
>
>  Register To Reply

5. In this formula

=IF(COUNTIF(A1:AS3,1),1,"")

the first 1 is what you're counting within the range. If the count is 0 then the formula will return "", i.e. a blank, if the count is anything else, i.e. 1 or higher the formula returns a 1.

If you were searching for something else in the range, e.g. a letter x then the formula would be

=IF(COUNTIF(A1:AS3,"x"),1,"")  Register To Reply

6. ## Re: Referencing a range of columns and rows with the IF function

I really need to just identify 1 only and nothing higher i.e =1
--
Cliff

>
> In this formula
>
> =IF(COUNTIF(A1:AS3,1),1,"")
>
> the first 1 is what you're counting within the range. If the count is 0
> then the formula will return "", i.e. a blank, if the count is anything
> else, i.e. 1 or higher the formula returns a 1.
>
> If you were searching for something else in the range, e.g. a letter x
> then the formula would be
>
> =IF(COUNTIF(A1:AS3,"x"),1,"")
>
>
> --
> ------------------------------------------------------------------------
>
>  Register To Reply

7. Not quite sure what you're saying. Do you want the formula to return a 1 only when there is only a single 1 in the range?

If so

=IF(COUNTIF(A1:AS3,1)=1,1,"")  Register To Reply

8. ## Re: Referencing a range of columns and rows with the IF function

I tried both of your formulas and they did not search the range of cells I
believe. With 1 in all referenced cells the formula cell was blank.
--
Cliff

>
> Not quite sure what you're saying. Do you want the formula to return a 1
> only when there is only a single 1 in the range?
>
> If so
>
> =IF(COUNTIF(A1:AS3,1)=1,1,"")
>
>
> --
> ------------------------------------------------------------------------
>
>  Register To Reply