sumproduct in vba

cmefly

Well-known Member
Joined
May 13, 2003
Messages
683
hi,

i'm trying to develop a code that searches column K for all occurrences of a certain string and adds up the associated values found in column I.

example: look for "def" within column K and and up column I

column i column K
1 abcdefghi
2 defghij
3 123defghijklm
4 _def_123
5 af;lkeion

any ideas on where to start????
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
i've got this but it's not working....HELP PLZ!

Code:
Sub testbi()
Dim y As Integer
y = Sheets("14. Analysis").Range("Z1").Value
x = 0

For Each cell In Sheets("4. schedule").Range("K49:k78").Cells
    If InStr(1, cell, y & "def") = 0 Then
    x = x + Sheets("4. schedule").Range("I" & cell.Row).Value
    End If
Next cell


Range("B19") = x



End Sub
 
Upvote 0
Excel Workbook
IJKL
1111.00abcdefghi1,110.00
2222.00defghij
3333.00123defghijklm
4444.00_def_123
5555.00af;lkeion
Sheet1
Excel 2007
Cell Formulas
RangeFormula
L1=SUMIF($K$1:$K$5,"*def*",I1:I5)
 
Upvote 0
The code equivalent is:

Code:
Sub Macro1()
    Range("L1").FormulaR1C1 = "=SUMIF(C11,""*def*"",C9)"  '(modified for full columns)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,165
Members
448,870
Latest member
max_pedreira

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