ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to express a set of cells as a range (https://www.excelbanter.com/excel-programming/436484-how-express-set-cells-range.html)

Robert Crandal

How to express a set of cells as a range
 
The following cells are only important to me: A1, B5, J20 and M6

I would like to use the above four cells with the Excel countif()
function as follows, but this does NOT work:

countif (A1,B5,J20,M6, 0) ' Does NOT work!

This does not work because countif() only accepts 2 parameters,
a range and a criteria.

How can I make this work?? I already tried the following:

countif(Range(A1,B5,J20,M6), 0 )

but that didn't seem to work either.

Please let me know what I'm missing.

thankx


Per Jessen

How to express a set of cells as a range
 
Hi

Look at this:

MyVar = WorksheetFunction.CountIf(Range("A1,B5,J20,M6"), 0)

Regards,
Per

"Robert Crandal" skrev i meddelelsen
...
The following cells are only important to me: A1, B5, J20 and M6

I would like to use the above four cells with the Excel countif()
function as follows, but this does NOT work:

countif (A1,B5,J20,M6, 0) ' Does NOT work!

This does not work because countif() only accepts 2 parameters,
a range and a criteria.

How can I make this work?? I already tried the following:

countif(Range(A1,B5,J20,M6), 0 )

but that didn't seem to work either.

Please let me know what I'm missing.

thankx



John

How to express a set of cells as a range
 
Whilst not 100% certain, I think that you will find what you are trying to do
is a weakness in Excel. You can use the functions on ranges that are
contiguous only.

A solution to this is that you add multiple formulas together that have each
of the contiguous ranges separated something like this:

=SUM(COUNTIF(A1,0),COUNTIF(B5,0),COUNTIF(J20,0),CO UNTIF(M6,0))

Hope helps

--
jb


"Robert Crandal" wrote:

The following cells are only important to me: A1, B5, J20 and M6

I would like to use the above four cells with the Excel countif()
function as follows, but this does NOT work:

countif (A1,B5,J20,M6, 0) ' Does NOT work!

This does not work because countif() only accepts 2 parameters,
a range and a criteria.

How can I make this work?? I already tried the following:

countif(Range(A1,B5,J20,M6), 0 )

but that didn't seem to work either.

Please let me know what I'm missing.

thankx

.


John_John

How to express a set of cells as a range
 
Use a new column (say column "N") to insert references to your cells like:

N1 : =A1
N2 : =B5
N3 : =J20
N4 : =M6

Then you can use COUNTIF() for this column ( column "N") to count zero values.

Ο χρήστης "Robert Crandal" *γγραψε:

The following cells are only important to me: A1, B5, J20 and M6

I would like to use the above four cells with the Excel countif()
function as follows, but this does NOT work:

countif (A1,B5,J20,M6, 0) ' Does NOT work!

This does not work because countif() only accepts 2 parameters,
a range and a criteria.

How can I make this work?? I already tried the following:

countif(Range(A1,B5,J20,M6), 0 )

but that didn't seem to work either.

Please let me know what I'm missing.

thankx

.



All times are GMT +1. The time now is 03:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com