Summing values based of adjacent value

RobertSi

New Member
Joined
Oct 15, 2015
Messages
4
Hi i have a table as follows and I would like to sum the values in column B based on the values in column A and place the answer in column D in order of column C. This is just an example of what i want the values are not 1, 2, 3 etc.

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]10[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]50[/TD]
[TD]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]42[/TD]
[TD]3[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]82[/TD]
[TD]4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]34[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]75[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]60[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]20[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]30[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I was thinking of using "for" statements but I'm unsure of whether that will actually work is there a way to do this?
I am using excel 2010 on windows 7. I am also a beginner when it comes to VBA.

Any help would be great thanks.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi. Read up on SUMIF. In this case your range will be A2:A10, your criteria C1 and your sum range B2:B10. If you are going to drag down the formula you must absolute the range and sum range.
 
Upvote 0
Thanks the SUMIF helped I used it as such

For a = 2 To 100
If Sheets(ComboBox1.Text).Range("M" & a) <> Blank Then
Sheets(ComboBox1.Text).Range("O" & a) = Application.WorksheetFunction.SumIf(Sheets(ComboBox1.Text).Range("F:F"), Sheets(ComboBox1.Text).Range("M" & a), Sheets(ComboBox1.Text).Range("E:E"))
End If
Next

And I got the result i wanted
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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