Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default Sumproduct problem

I am trying to use an array value in a sumprodct function using Evaluate
under VBA My code looks like this:
Evaluate("=SUMPRODUCT(--(Arr(i)" & _
"Billable FT'!" & CntRef.Address & """0""),--('Arr(i)" & _
"Billable FT'!" & CntRef2.Address)

Where CntRef is a range and both are the same size, "Arr(i)" is the array. I
think I have all the right Quotes and &'s. I get a #Value Error when I run
the code

Help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Sumproduct problem

Helen,

SUMPRODUCT is a worksheet function. The array as you have it is a VBA v
ariable. You cannot plug the latter directly into the former.

If array(i) holds say asheet reference or a workbook name, you need the
formula to resolve, so that means in the VBA, not in the SUMPRODUCT formula,
maybe like

Evaluate("=SUMPRODUCT(--(" & Arr(i) & _
"Billable FT'!" & CntRef.Address & """0""),--('" & Arr(i) & _
"Billable FT'!" & CntRef2.Address)

--
HTH

Bob Phillips

"Helen" wrote in message
...
I am trying to use an array value in a sumprodct function using Evaluate
under VBA My code looks like this:
Evaluate("=SUMPRODUCT(--(Arr(i)" & _
"Billable FT'!" & CntRef.Address & """0""),--('Arr(i)" & _
"Billable FT'!" & CntRef2.Address)

Where CntRef is a range and both are the same size, "Arr(i)" is the array.

I
think I have all the right Quotes and &'s. I get a #Value Error when I run
the code

Help



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sumproduct problem

Just a heads up to the OP. Bob gave an excellent explanation of the
immediate issue, but there are additional flaws in your original formula.
See my post for additional considerations.



--
regards,
Tom Ogilvy

"Bob Phillips" wrote in message
...
Helen,

SUMPRODUCT is a worksheet function. The array as you have it is a VBA v
ariable. You cannot plug the latter directly into the former.

If array(i) holds say asheet reference or a workbook name, you need the
formula to resolve, so that means in the VBA, not in the SUMPRODUCT

formula,
maybe like

Evaluate("=SUMPRODUCT(--(" & Arr(i) & _
"Billable FT'!" & CntRef.Address & """0""),--('" & Arr(i) &

_
"Billable FT'!" & CntRef2.Address)

--
HTH

Bob Phillips

"Helen" wrote in message
...
I am trying to use an array value in a sumprodct function using Evaluate
under VBA My code looks like this:
Evaluate("=SUMPRODUCT(--(Arr(i)" & _
"Billable FT'!" & CntRef.Address & """0""),--('Arr(i)" & _
"Billable FT'!" & CntRef2.Address)

Where CntRef is a range and both are the same size, "Arr(i)" is the

array.
I
think I have all the right Quotes and &'s. I get a #Value Error when I

run
the code

Help





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sumproduct problem

Assuming Arr(i) holds some type of qualifier that completes a sheetname

Evaluate("=SUMPRODUCT(--('" & Arr(i) & _
"Billable FT'!" & CntRef.Address & """0""),--('" & Arr(i) & _
"Billable FT'!" & CntRef2.Address & "))")

Now benchtest it in the immediate window:

arr = Array("My","Your")
i = 1
? arr(i)
Your
set cntRef = Range("A1:A10")
set cntRef2 = Range("B1:B10")
? "=SUMPRODUCT(--('" & Arr(i) & _
"Billable FT'!" & CntRef.Address & """0""),--('" & Arr(i) & _
"Billable FT'!" & CntRef2.Address & "))"
=SUMPRODUCT(--('YourBillable FT'!$A$1:$A$10"0"),--('YourBillable
FT'!$B$1:$B$10))

That should be pretty close.

--
Regards,
Tom Ogilvy




"Helen" wrote in message
...
I am trying to use an array value in a sumprodct function using Evaluate
under VBA My code looks like this:
Evaluate("=SUMPRODUCT(--(Arr(i)" & _
"Billable FT'!" & CntRef.Address & """0""),--('Arr(i)" & _
"Billable FT'!" & CntRef2.Address)

Where CntRef is a range and both are the same size, "Arr(i)" is the array.

I
think I have all the right Quotes and &'s. I get a #Value Error when I run
the code

Help



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sumproduct problem

based on your later posting example of

Cells(49, C) = Workbooks(WrkBk).Worksheets("Billable
FT").WorksheetFunction.Subtotal(9, xlRng)

I hope Arr(i) holds something like [Mybook1.xls]
including the square brackets.

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Assuming Arr(i) holds some type of qualifier that completes a sheetname

Evaluate("=SUMPRODUCT(--('" & Arr(i) & _
"Billable FT'!" & CntRef.Address & """0""),--('" & Arr(i) &

_
"Billable FT'!" & CntRef2.Address & "))")

Now benchtest it in the immediate window:

arr = Array("My","Your")
i = 1
? arr(i)
Your
set cntRef = Range("A1:A10")
set cntRef2 = Range("B1:B10")
? "=SUMPRODUCT(--('" & Arr(i) & _
"Billable FT'!" & CntRef.Address & """0""),--('" & Arr(i) &

_
"Billable FT'!" & CntRef2.Address & "))"
=SUMPRODUCT(--('YourBillable FT'!$A$1:$A$10"0"),--('YourBillable
FT'!$B$1:$B$10))

That should be pretty close.

--
Regards,
Tom Ogilvy




"Helen" wrote in message
...
I am trying to use an array value in a sumprodct function using Evaluate
under VBA My code looks like this:
Evaluate("=SUMPRODUCT(--(Arr(i)" & _
"Billable FT'!" & CntRef.Address & """0""),--('Arr(i)" & _
"Billable FT'!" & CntRef2.Address)

Where CntRef is a range and both are the same size, "Arr(i)" is the

array.
I
think I have all the right Quotes and &'s. I get a #Value Error when I

run
the code

Help







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
SumProduct problem John Excel Worksheet Functions 5 February 23rd 09 01:52 AM
Sumproduct #Value! Problem deeds Excel Worksheet Functions 8 May 5th 08 05:01 PM
SUMPRODUCT #VALUE! problem Vibeke Excel Worksheet Functions 4 March 18th 07 04:46 AM
sumproduct problem andy New Users to Excel 2 March 29th 06 01:52 PM
sumproduct problem Stefan Excel Worksheet Functions 2 January 5th 06 10:59 AM


All times are GMT +1. The time now is 04:56 PM.

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

About Us

"It's about Microsoft Excel"