ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Combine various cells in to one array (https://www.excelbanter.com/excel-worksheet-functions/264224-combine-various-cells-one-array.html)

Odin

Combine various cells in to one array
 
I have the following formula that I would like to shorten it. Is it possible?

=12.5%*(($A$1=$C1)+(($A$1=$C6)*2)+(($A$1=$C11)*3)+ (($A$1=$C16)*4)+(($A$1=$C21)*5))

To following is just an idea but doesn't work on excel.

=12.5%*(($C1,$C6,$C11,$C16,$C21)=$A$1)*{1,2,3,4,5}

I wanted to use SUMPRODUCT but it only take contiguous array. Thanks for any input.

PS: I can not use array C1:C21 because other cells within it may equal to $A$1 which will return incorrect result. And the 3rd part, {1,2...} would be too long.

Lars-Åke Aspelin[_4_]

Combine various cells in to one array
 
On Thu, 20 May 2010 20:38:45 +0100, Odin
wrote:


I have the following formula that I would like to shorten it. Is it
possible?

=12.5%*(($A$1=$C1)+(($A$1=$C6)*2)+(($A$1=$C11)*3) +(($A$1=$C16)*4)+(($A$1=$C21)*5))

To following is just an idea but doesn't work on excel.

=12.5%*(($C1,$C6,$C11,$C16,$C21)=$A$1)*{1,2,3,4,5 }

I wanted to use SUMPRODUCT but it only take contiguous array. Thanks
for any input.

PS: I can not use array C1:C21 because other cells within it may equal
to $A$1 which will return incorrect result. And the 3rd part, {1,2...}
would be too long.


Try this formula, it is 19 characters shorter than the one you have:

=12.5%*SUMPRODUCT((MOD(ROW(5:25),5)=0)*ROW(5:25)/5*(C1:C21=A1))

Hope this helps / Lars-Åke



All times are GMT +1. The time now is 10:31 PM.

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