SUMPRODUCT code does nothing?

Status
Not open for further replies.

Drawleeh

New Member
Joined
Sep 2, 2021
Messages
34
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
I have the following code, I am trying to use the SUMPRODUCT function, I want to loop through all the concatenated values in A and B and then use that info in the SUMPRODUCT. But my code isn't doing anything or throwing up any errors. I don't see why it doesn't work?

VBA Code:
Sub SumData()
Dim val As Long
Dim Concat(2 To 250) As Variant

For val = 2 To 250
Concat(val) = Cells(val, 1) & " " & Cells(val, 2)

Evaluate ("=SUMPRODUCT(--(Concat(Val)=Cell(Val,9)),Cell(Val,4),Cell(Val,6))")
With ThisWorkbook.Worksheets("Sheet1").Range("K2:K250")
End With
Next val
    
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
The correct syntax would be something like this. Note that I've changed the name of the array from Concat to cArray. Excel contains a function called Concat so you are at risk of conflict errors.

VBA Code:
Sub SumData()
Dim val As Long
Dim cArray(2 To 250) As Variant

For val = 2 To 250
    cArray(val) = Cells(val, 1) & " " & Cells(val, 2)
   
    ThisWorkbook.Worksheets("Sheet1").Cells(val, 11).Value = Evaluate ("=SUMPRODUCT(--(" & cArray(Val) & "=" & Cells(Val,9) & ")," & Cells(Val,4) & "," & Cells(Val,6) & ")")
Next val
    
End Sub
 
Upvote 0
Duplicate to: Concatenate values into range VBA

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,723
Messages
6,174,123
Members
452,546
Latest member
Rafafa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top