Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default INDEX return multiple columns

I have the following data

Range1 (1x4)
id 1 3 5

Range2 (3x1)
2
4
6

The goal is very simple. I want to extract the numbers in Range1, then sum product them with Range2.

To extract numbers - Index(Range1, 1, {2,3,4})
Then multiply - MMULT(Index(Range1, 1, {2,3,4}), Range2)

The problem is since the result is single-cell, even I instructed cell to use an array formula, it defaulted back to regular formula. As a result, Index(Range1, 1, {2,3,4}) returned a 1x1 array instead of a 1x3 array, causing MMULT to fail.

Because of this, TRANSPOSE + SUMPRODUCT didn't work neither.

I then thought about creating an IndexWrapper function in VBA to force it to return an array.

' As a Test
Public Function IndexWrapper (arr As range) As Variant()

Dim cols(3) As Double
cols(1) = 2
cols(2) = 3
cols(3) = 4

IndexWrapper = WorksheetFunction.Index(arr, 1, cols)

End Function

WorksheetFunction.Index doesn't seem to take the cols into consideration. The entire row is returned.

Anyone has a good solution for this problem? I am trying not to create an one off work around. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default INDEX return multiple columns

I know I'm probably missing the problem here, but
B1:D1 has 1,3,5
A2:A4 has 2,4,6
then D4 has =MMULT(B1:D1,A2:A4)
which gives 44. From here, whither?
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Match / Index multiple criteria return multiple results Marty Excel Worksheet Functions 2 May 22nd 10 01:49 PM
INDEX function multiple columns & rows jasebeds Excel Worksheet Functions 2 August 27th 06 05:41 PM
Lookup in Multiple Columns, Return Multiple Values andy62 Excel Worksheet Functions 3 July 6th 06 02:36 AM
Index/Match from multiple columns hgopp99 Excel Worksheet Functions 5 January 21st 06 06:13 PM
return multiple corresponding values using INDEX BubbleGum Excel Worksheet Functions 2 January 5th 06 05:43 AM


All times are GMT +1. The time now is 10:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"