LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default can i use sumproduct this way in VB?

You've got a few typos in your code--"a1 and "b1 are missing ending quotes. And
each of those cells is missing the worksheet name:

Worksheets.Range("A1)



You can use application.evaluate to do what you want.

I like this style:

Option Explicit
Sub testme02()

Dim RngA As Range
Dim RngB As Range
Dim RngC As Range
Dim CellA As Range
Dim CellB As Range

Dim myFormula As String

With Worksheets("a")
Set RngA = .Range("a2:A9")
Set RngB = .Range("b2:b9")
Set RngC = .Range("c2:c9")
Set CellA = .Range("a1")
Set CellB = .Range("B1")
End With

myFormula = "sumproduct(--(" & RngA.Address(external:=True) _
& "=" & CellA.Address(external:=True) & ")," _
& "--(" & RngB.Address(external:=True) _
& "=" & CellB.Address(external:=True) & ")," _
& "(" & RngC.Address(external:=True) & "))"

Debug.Print myFormula 'nice for testing!

MsgBox Application.Evaluate(myFormula)

End Sub

Andy wrote:

Can i use sumproduct in VB the same way in a cell of excel. The only
difference being i am using
application.worksheetfunction.sumproduct(--(Worksheets("A").Range("A2:A9") _
=Worksheets.Range("A1),--(Worksheets("A").Range("b2:b9") _
=Worksheets.Range("b1),--(Worksheets("A").Range("c2:c9"))

Is that possible, or do i need to use a different method to accomplish the
same task?


--

Dave Peterson
 
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 with Condition OR Sumproduct with ADDRESS function - HE gholly Excel Discussion (Misc queries) 2 September 28th 09 05:07 PM
Help with SUMPRODUCT Alex Mackenzie Excel Worksheet Functions 7 May 15th 09 08:17 PM
Conditional SUMPRODUCT or SUMPRODUCT with Filters Ted M H Excel Worksheet Functions 4 August 14th 08 07:50 PM
sumproduct? sumif(sumproduct)? David Excel Worksheet Functions 3 July 13th 07 07:06 PM
sumproduct Mandy Excel Discussion (Misc queries) 3 February 8th 06 01:25 PM


All times are GMT +1. The time now is 07:00 AM.

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"