Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default passing array reference to sumproduct formula-???

I have a UDF (see bottom) which finds a particular col header then looks up a
range in that column. I want to pass this range to a sumproduct formula in
another cell:

=SUMPRODUCT(((TRIM($A$8:$A46)="A")+(TRIM($A$8:$A46 )="B")+(TRIM($A$8:$A46)="C")+(TRIM($A$8:$A46)="D") )*((TRIM($B$8:$B46)="E")),C$8:C46)

So for the above, C$8:C46 would be replaced by REFR()

REFR works fine, returning the correct range reference, but when i put it in
the sumproduct formula a value error results.

Please help

Thanks

Function REFR(Product As Range, Colhead As Range)

Application.Volatile

Dim c As Range
Dim productstring As String
Dim cs As Integer
Dim rs As Integer
Dim sumthese As Variant

productstring = Product.Value


For Each c In Colhead.Cells

If Trim(c) = Trim(productstring) Then

cs = c.Column
rs = c.Row + 1

Set sumthese = Range(Cells(rs, cs), Cells(rs + 35, cs))

Else: End If

Next c

REFR = sumthese.Address(rowabsolute:=False, columnabsolute:=False)

End Function

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default passing array reference to sumproduct formula-???

Untested:

=SUMPRODUCT(((TRIM($A$8:$A46)="A")
+(TRIM($A$8:$A46)="B")
+(TRIM($A$8:$A46)="C")
+(TRIM($A$8:$A46)="D"))
*((TRIM($B$8:$B46)="E")),
indirect(refr(rng1,rng2)))

(change rng1 and rng2 to the addresses you need)



PBcorn wrote:

I have a UDF (see bottom) which finds a particular col header then looks up a
range in that column. I want to pass this range to a sumproduct formula in
another cell:

=SUMPRODUCT(((TRIM($A$8:$A46)="A")+(TRIM($A$8:$A46 )="B")+(TRIM($A$8:$A46)="C")+(TRIM($A$8:$A46)="D") )*((TRIM($B$8:$B46)="E")),C$8:C46)

So for the above, C$8:C46 would be replaced by REFR()

REFR works fine, returning the correct range reference, but when i put it in
the sumproduct formula a value error results.

Please help

Thanks

Function REFR(Product As Range, Colhead As Range)

Application.Volatile

Dim c As Range
Dim productstring As String
Dim cs As Integer
Dim rs As Integer
Dim sumthese As Variant

productstring = Product.Value

For Each c In Colhead.Cells

If Trim(c) = Trim(productstring) Then

cs = c.Column
rs = c.Row + 1

Set sumthese = Range(Cells(rs, cs), Cells(rs + 35, cs))

Else: End If

Next c

REFR = sumthese.Address(rowabsolute:=False, columnabsolute:=False)

End Function


--

Dave Peterson
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
Help with Possible Array or Sumproduct Formula Steph Excel Worksheet Functions 7 February 23rd 08 08:55 PM
Passing Array Formula result to a variable in VBA (Leo) Leo Excel Programming 2 December 25th 07 06:22 AM
SUMPRODUCT array formula avi Excel Programming 6 November 21st 07 07:07 AM
SUMPRODUCT as array formula? Henrik Excel Worksheet Functions 2 November 2nd 05 07:08 AM
How can I use a cell reference in Sumproduct array formula? Chrism Excel Discussion (Misc queries) 1 April 7th 05 05:05 PM


All times are GMT +1. The time now is 07:58 PM.

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"