Hi All,
I'm after some help with the sumproduct formula.
I need to count the number of cells <>0.
My problem is that the cells are not in sequence i.e A1,C1,E1,G1.
Any idea's ?
Hi All,
I'm after some help with the sumproduct formula.
I need to count the number of cells <>0.
My problem is that the cells are not in sequence i.e A1,C1,E1,G1.
Any idea's ?
Use:
=SUMPRODUCT(--(MOD(COLUMN(A1:Z1),2)=1),--(A1:Z1<>0))
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
The example will Count the instances of "Odd" columns where the value contained within does not equal 0.
In XL columns can be referred to by their column number ie A=1, B=2 as Z=26 and AA = 27 etc... the example simply tests the Remainder of the Column number once divided by a divisor of 2 --- where the remainder is 1 we know the Column is "odd" (ie A,C,E etc...).
For more info on MOD See XL Help.
It will depend on how many you're referring to... you can use a variety of methods in truth but which will be dependent upon the count...
You could use something as basic as:
=SUM(--(N(A1)<>0),--(N(G1)<>0),--(N(S1)<>0))+COUNTIF(L1:N1,"<>0")
ie treat non contiguous ranges slightly differently...
You could use things like ERROR.TYPE & named range, INDIRECT, CHOOSE but I think we'd need more info.
Perhaps the easiest option would be to add an indicator in a blank row to denote those to be validated...?
eg say row 1 had "x" in A, G, L:N, S then you could use the below to count non-zero values in row 2 within those x columns using:
=SUMPRODUCT(--($A$1:$Z$1="x"),--($A2:$Z2<>0))
You can use another row to indicate the columns of interest:
=SUMPRODUCT( (A$1:Z$1 = "x") * (A2:Z2<>0) )
Entia non sunt multiplicanda sine necessitate
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks