Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default VBA SumProduct Problems Contiued

I have been posting similar questions the last few days and thought I had all
my answers. Turns out, I don't. Here is my code:

Private Sub CommandButton1_Click()

Dim OutReach As Range
Dim WS As Worksheet
Dim AgeRange As String

Set WS = Worksheets("Sheet1")
Set OutReach = WS.Range("A15")
AgeRange = "B1:B10"


OutReach.Value = WS.Evaluate("=SUMPRODUCT((" & AgeRange & "
1)*(D1:F10=I1))")


End Sub


This code works great and does exactly what that I want it to. However, in
the formula line, instead of D1:F10 = I1, I want D1:F10 =
Worksheets("Sheet2").Range("A1").Value

This gives and error.

I basically want this formlua to look to Sheet2???


--
Thanks
Shawn
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default VBA SumProduct Problems Contiued

Hi,

Try this:

OutReach.Value = WS.Evaluate("=SUMPRODUCT((" & AgeRange & "1)*(D1:F10=" &
Worksheets("Sheet2").Range("A1").Value & "))")

HTH

"Shawn" wrote:

I have been posting similar questions the last few days and thought I had all
my answers. Turns out, I don't. Here is my code:

Private Sub CommandButton1_Click()

Dim OutReach As Range
Dim WS As Worksheet
Dim AgeRange As String

Set WS = Worksheets("Sheet1")
Set OutReach = WS.Range("A15")
AgeRange = "B1:B10"


OutReach.Value = WS.Evaluate("=SUMPRODUCT((" & AgeRange & "
1)*(D1:F10=I1))")


End Sub


This code works great and does exactly what that I want it to. However, in
the formula line, instead of D1:F10 = I1, I want D1:F10 =
Worksheets("Sheet2").Range("A1").Value

This gives and error.

I basically want this formlua to look to Sheet2???


--
Thanks
Shawn

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default VBA SumProduct Problems Contiued

I pasted your code exactly and it didn't work. I changed my D1:F10 range
from text items to value items and it then worked. So it has something to do
with the fact that text is stored in the reference cells instead of values.
What do I do?

--
Thanks
Shawn


"Toppers" wrote:

Hi,

Try this:

OutReach.Value = WS.Evaluate("=SUMPRODUCT((" & AgeRange & "1)*(D1:F10=" &
Worksheets("Sheet2").Range("A1").Value & "))")

HTH

"Shawn" wrote:

I have been posting similar questions the last few days and thought I had all
my answers. Turns out, I don't. Here is my code:

Private Sub CommandButton1_Click()

Dim OutReach As Range
Dim WS As Worksheet
Dim AgeRange As String

Set WS = Worksheets("Sheet1")
Set OutReach = WS.Range("A15")
AgeRange = "B1:B10"


OutReach.Value = WS.Evaluate("=SUMPRODUCT((" & AgeRange & "
1)*(D1:F10=I1))")


End Sub


This code works great and does exactly what that I want it to. However, in
the formula line, instead of D1:F10 = I1, I want D1:F10 =
Worksheets("Sheet2").Range("A1").Value

This gives and error.

I basically want this formlua to look to Sheet2???


--
Thanks
Shawn

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default VBA SumProduct Problems Contiued

I figured out the answer. Here is an example:

Private Sub CommandButton1_Click()

Dim OutReach As Range
Dim WS As Worksheet
Dim AgeRange As String
Dim Red As Range

Set WS = Worksheets("Sheet1")
Set OutReach = WS.Range("A15")
Set Red = WS.Range("I1")
AgeRange = "B1:B10"


OutReach.Value = WS.Evaluate("=SUMPRODUCT((" & AgeRange &
"1)*(D1:F10=""" & Red.Value & """))")

WS.Range("A16").Value = Red.Value

End Sub


--
Thanks
Shawn


"Shawn" wrote:

I have been posting similar questions the last few days and thought I had all
my answers. Turns out, I don't. Here is my code:

Private Sub CommandButton1_Click()

Dim OutReach As Range
Dim WS As Worksheet
Dim AgeRange As String

Set WS = Worksheets("Sheet1")
Set OutReach = WS.Range("A15")
AgeRange = "B1:B10"


OutReach.Value = WS.Evaluate("=SUMPRODUCT((" & AgeRange & "
1)*(D1:F10=I1))")


End Sub


This code works great and does exactly what that I want it to. However, in
the formula line, instead of D1:F10 = I1, I want D1:F10 =
Worksheets("Sheet2").Range("A1").Value

This gives and error.

I basically want this formlua to look to Sheet2???


--
Thanks
Shawn

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 problems Fergus Excel Discussion (Misc queries) 2 April 20th 09 05:56 AM
I, too, am having problems with SUMPRODUCT Leonhardtk Excel Worksheet Functions 5 July 18th 07 06:05 PM
Sumproduct problems... Johnny M[_2_] Excel Worksheet Functions 4 March 22nd 07 09:14 PM
SUMPRODUCT problems mmcap Excel Worksheet Functions 2 January 30th 07 06:50 PM
Problems with sumproduct Rob_T Excel Worksheet Functions 1 June 26th 06 11:47 AM


All times are GMT +1. The time now is 04:27 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"