# Macro - Sum of all "A" corresponding value from column F:I

#### baps2013

##### New Member
Hello,

I am new to excel VBA , need you help for this problem.

I have attached data file for which I need a Marco to get the sum of each grade value corresponding from Q1 to Q4.

Result explected:

 Grade Total A 1068 (result) B C D

<tbody>
</tbody>

Attached excel file

 Grade Q1 Q2 Q3 Q4 A 10 80 50 100 A 10 10 50 10 B 35 35 35 35 B 60 45 60 78 A 45 78 56 90 D 10 67 78 10 A 35 35 10 35 A 40 60 35 89 B 20 50 78 90 B 10 10 10 10 A 35 35 35 35 D 60 35 35 40

<tbody>
</tbody><colgroup><col span="5"><col span="3"><col></colgroup>

### Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

#### nuked

##### Well-known Member
=SUM(((F2:F13) + (G2:G13)+(H2:H13)+(I2:I13)) * (A2:A13="A"))
=SUM(((F2:F13) + (G2:G13)+(H2:H13)+(I2:I13)) * (A2:A13="B"))
=SUM(((F2:F13) + (G2:G13)+(H2:H13)+(I2:I13)) * (A2:A13="C"))
=SUM(((F2:F13) + (G2:G13)+(H2:H13)+(I2:I13)) * (A2:A13="D"))

Assuming your data starts in A1

You'll need to enter these as array formulas so instead of pressing "Enter" once you've pasted it, you'll need to do "Ctrl" + "Shift" + "Enter"

#### AlphaFrog

##### MrExcel MVP
This macro puts the results in columns K:L

Code:
``````[color=darkblue]Sub[/color] Annual_Grade_Totals()
Range("K2:K5").Value = Application.Transpose(Array("A", "B", "C", "D"))
Range("L2").Value = Evaluate("=SUMPRODUCT(--(A2:A13=""A""),(F2:F13+G2:G13+H2:H13+I2:I13))")
Range("L3").Value = Evaluate("=SUMPRODUCT(--(A2:A13=""B""),(F2:F13+G2:G13+H2:H13+I2:I13))")
Range("L4").Value = Evaluate("=SUMPRODUCT(--(A2:A13=""C""),(F2:F13+G2:G13+H2:H13+I2:I13))")
Range("L5").Value = Evaluate("=SUMPRODUCT(--(A2:A13=""D""),(F2:F13+G2:G13+H2:H13+I2:I13))")
[color=darkblue]End[/color] [color=darkblue]Sub[/color]``````

#### baps2013

##### New Member
Thanks nuked

Thanks AlphaFrog

I tried the code and it is working fine. First time tried and successful.

Thanks once again

Regards,
Baps

Replies
5
Views
334
Replies
4
Views
190
Replies
3
Views
102
Replies
0
Views
144
Replies
11
Views
230

1,195,858
Messages
6,011,983
Members
441,661
Latest member
Pammie007

### 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.

### Which adblocker are you using?

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

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