VBA Evaluate and Sum

LionRunner

New Member
Joined
Nov 13, 2014
Messages
19
Hello,

My data is set up as can be seen at the bottom.

In VBA I am trying to evaluate column "Prodcut" for the value Product2, and in the if Product2 is in column Product I would like to sum the numeric values listed in column "Nov14" for the rows that correspond to the Prodcut2 values and and place that sum in cell T3.

The first thing is I'm getting a type mismatch prompt in my "For i" statment, highlighting the i. Then I don't think sum is correct but I don't know how to tell it to sum in VBA.

Can someone help. Thank you.
See my code so far:

Sub IGraph()
Dim Product As String, Nov13 As String, Nov14 As String, Nov13Sum As String, Nov14Sum As String, i As String

For i = 5 To 1000
Product = Cells(i, 2).Value
Nov14 = Cells(i, 8).Value
Nov14Sum = Cells(T3).Value

If Product = "Product2" Then
Nov14Sum = Sum(Nov14)
End If

End Sub




Product
Nov13
Nov14
Product 1
503
582
Product 2
323
323
Product 3
453
428
Product 4
613
701
Product 5
4
3
Product 6
465
281
Product 1
1039
857
Product 2
0
0
Product 3
754
224
Product 4
1907
2570
Product 5
472
492
Product 6
61
62
Product 1
1550
1650
Product 2
503
582
Product 3
323
323
Product 4
453
428
Product 5
613
701
Product 6
4
3
Product 1
465
281
Product 2
1039
857
Product 3
0
0
Product 4
754
224
Product 5
1907
2570
Product 6
472
492
Product 1
61
62
Product 2
1550
1650

<TBODY>
</TBODY>

<TBODY>
</TBODY>
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Yes, sumif will work in the immediacy for this one operation; but there are numerous operations that have to be peformed on the results, and then other operations performed of the results of those results. You get very complicated Excel files with tables and sub-tables of data all over the place on numberous tabs, running off the view screen. It's a big mess.

That's why I wanted to write it in VBA. Thats the way things are now and I want to get away from this nonsense.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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