VBA find Max, Min and Sum

MikeCook69

New Member
Joined
Jun 4, 2018
Messages
4
I have 2 worksheets. The first work sheet has my raw data. The second worksheet has a list that I am trying to find the max and min values of the raw data and the sum. My data is not sorted.

Worksheet 1
ABCD
g1410
e2312
g1214
g4416
e3514
f2613
e4310
g2212

<tbody>
</tbody>

Worksheet 2
AMin BMax CSum D
g
e

<tbody>
</tbody>

So I'm trying to get the following results.

AMin BMax CSum D
g1452
e2436

<tbody>
</tbody>

I was trying to use a loop with nested if statements but I'm not sure if that is the most efficient method. I also might be making this more complicated that I need to.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
A
B
C
D
E
F
G
H
I
1
g
1​
4​
10​
Min BMax CSum
2
e
2​
3​
12​
g
1​
4​
52​
3
g
1​
2​
14​
e
2​
4​
4
g
4​
4​
16​
5
e
3​
5​
14​
6
f
2​
6​
13​
7
e
4​
3​
10​
8
g
2​
2​
12​
Sheet: Sheet18

Formula in cell I2:
=SUMIFS($D$1:$D$8,$A$1:$A$8,F2,$B$1:$B$8,">="&G2,$C$1:$C$8,"<="&H2)

Code:
Sub Macro1()


    Range("I2").Formula = "=SUMIFS($D$1:$D$8,$A$1:$A$8,F2,$B$1:$B$8,"">=""&G2,$C$1:$C$8,""<=""&H2)"


End Sub
 
Upvote 0

Forum statistics

Threads
1,217,087
Messages
6,134,485
Members
449,874
Latest member
Cl2130

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