ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   2 loops? got me spinning (https://www.excelbanter.com/excel-programming/432385-2-loops-got-me-spinning.html)

John

2 loops? got me spinning
 
I have States in column D and a percentage in column Z (on Data sheet). I
would like to loop through rows in the sheet and sum column Z for each state
in column D. The list of States is on worksheet States and column C.

For example... TX may show up twice on Data sheet and would like a sum for
the number in column Z for Texas. Can I put that total on the States sheet
in column D next to the state abbreviation?

Any help is appreciated

EricG

2 loops? got me spinning
 
Probably don't need VBA for this. Type this formula into an empty next to
column D and drag down. Should do the summing you want for each state:

=SUMIF(Data!D2:D100,States!C2,Data!Z2:Z100)

Adjust the formula to suit your data and columns, then drag down to sum all
50 states.

HTH,

Eric

"John" wrote:

I have States in column D and a percentage in column Z (on Data sheet). I
would like to loop through rows in the sheet and sum column Z for each state
in column D. The list of States is on worksheet States and column C.

For example... TX may show up twice on Data sheet and would like a sum for
the number in column Z for Texas. Can I put that total on the States sheet
in column D next to the state abbreviation?

Any help is appreciated



All times are GMT +1. The time now is 01:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com