MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Mar 30th, 2004, 07:44 PM   #1
jcvoth
 
Join Date: Feb 2004
Posts: 198
Default Sumproduct within a ub

This a continuation of my post in

http://www.mrexcel.com/board2/viewtopic.php?t=83204

but because the question is unrelated to For Each, I think it is more appropriately in another topic.

My goal is to do a sumproduct within a sub. The following formula works correctly.

=SUMPRODUCT(($C$2:$C$9=H3)*($D$2:$D$9=I3)*($A$2:$A$9<=G3)*($B$2:$B$9>=G3)*($E$2:$E$9))

However, the problem gets more complicated when the lookups reside in another document. I felt it would be more appropriate to automate the task in a sub. What follows is where I am so far:

Dim cctr As Integer
mytimer = Timer
master = "E:\Sales Accounting\D F I\DFI Master File.xls"
'Workbooks.Open Filename:=(master)
'ActiveWindow.ActivateNext
lastrow = Range("A65536").End(xlUp).Row
cctr = InputBox("What Cost Center should be updated?")
Set BEGrange = Workbooks("DFI Master File.xls").Worksheets("Price Lists").Range("a2:a9000")
Set ENDrange = Workbooks("DFI Master File.xls").Worksheets("Price Lists").Range("b2:b9000")
Set PLrange = Workbooks("DFI Master File.xls").Worksheets("Price Lists").Range("c2:c9000")
Set ITrange = Workbooks("DFI Master File.xls").Worksheets("Price Lists").Range("d2:d9000")
Set DPrange = Workbooks("DFI Master File.xls").Worksheets("Price Lists").Range("e2:e9000")
For i = 2 To lastrow

If Range("v" & i).Value = cctr Then Range("H" & i).Value = Application.WorksheetFunction.SumProduct((PLrange = Range("p" & i).String) * (ITrange = Range("f" & i).String) * (BEGrange <= Range("e" & i).Value) * (ENDrange >= Range("e" & i).Value) * (DPrange))

Next i


I am defining the lookup paths for each portion of the array to simplify the application code. The error I am receiving is a runtime error. Object doesn't support this product or method.

I interpret this error to mean there is a problem with the equation syntax, but for the life of me, I cannot figure out what it is.

Thank you for taking the time to read this far!

-Jarrod
jcvoth is offline   Reply With Quote
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 02:22 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.