VBA to sum values in one column based on criteria of another column

Jim885

Well-known Member
Joined
Jul 8, 2012
Messages
663
I need someone to help me with this, as I can't figure out how to do it.

The below sample is an accurate example of a much larger set of data that I need help with. Column H will be my desired result.
I need a macro that will look at the matching values (numerical value of month) of Column F, then enter the sum of the corresponding values (rows) contained in Column D for that month. The sum of each month should be placed in Column H at the last value of the row for each particular month.

Thanks to everyone for looking at this.

[TABLE="width: 391"]
<colgroup><col style="width: 27pt; mso-width-source: userset; mso-width-alt: 1316;" width="36"> <col style="width: 48pt;" width="64"> <col style="width: 22pt; mso-width-source: userset; mso-width-alt: 1060;" width="29"> <col style="width: 57pt; mso-width-source: userset; mso-width-alt: 2779;" width="76"> <col style="width: 45pt; mso-width-source: userset; mso-width-alt: 2194;" width="60"> <col style="width: 48pt;" span="4" width="64"> <tbody>[TR]
[TD="class: xl73, width: 36, bgcolor: #BFBFBF"] [/TD]
[TD="class: xl65, width: 64, bgcolor: #BFBFBF"]A[/TD]
[TD="class: xl65, width: 29, bgcolor: #BFBFBF"]B[/TD]
[TD="class: xl65, width: 76, bgcolor: #BFBFBF"]C[/TD]
[TD="class: xl65, width: 60, bgcolor: #BFBFBF"]D[/TD]
[TD="class: xl65, width: 64, bgcolor: #BFBFBF"]E[/TD]
[TD="class: xl65, width: 64, bgcolor: #BFBFBF"]F[/TD]
[TD="class: xl65, width: 64, bgcolor: #BFBFBF"]G[/TD]
[TD="class: xl65, width: 64, bgcolor: #BFBFBF"]H[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]1[/TD]
[TD="class: xl72, bgcolor: transparent"]Item#[/TD]
[TD="class: xl72, bgcolor: transparent"] [/TD]
[TD="class: xl72, bgcolor: transparent"]Description[/TD]
[TD="class: xl72, bgcolor: transparent"]Quantity[/TD]
[TD="class: xl72, bgcolor: transparent"] [/TD]
[TD="class: xl72, bgcolor: transparent"]Month[/TD]
[TD="class: xl72, bgcolor: transparent"]Year[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]2[/TD]
[TD="class: xl82, bgcolor: #FCD5B4, align: right"]1001[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl82, bgcolor: #FCD5B4"]Item 1[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]3[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl71, bgcolor: transparent"] [/TD]
[TD="class: xl71, bgcolor: transparent"] [/TD]
[TD="class: xl71, bgcolor: transparent"] [/TD]
[TD="class: xl71, bgcolor: transparent"] [/TD]
[TD="class: xl71, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]4[/TD]
[TD="class: xl67, bgcolor: transparent"]Date[/TD]
[TD="class: xl68, width: 29, bgcolor: transparent"]Transaction Description[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]5[/TD]
[TD="class: xl69, bgcolor: transparent"]5/21/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl74, bgcolor: #8DB4E2"]8.00[/TD]
[TD="class: xl75, bgcolor: #8DB4E2"] [/TD]
[TD="class: xl75, bgcolor: #8DB4E2, align: right"]5[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]6[/TD]
[TD="class: xl69, bgcolor: transparent"]5/24/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl74, bgcolor: #8DB4E2"]16.00[/TD]
[TD="class: xl75, bgcolor: #8DB4E2"] [/TD]
[TD="class: xl75, bgcolor: #8DB4E2, align: right"]5[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]7[/TD]
[TD="class: xl69, bgcolor: transparent"]5/31/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl74, bgcolor: #8DB4E2"]20.00[/TD]
[TD="class: xl75, bgcolor: #8DB4E2"] [/TD]
[TD="class: xl75, bgcolor: #8DB4E2, align: right"]5[/TD]
[TD="class: xl75, bgcolor: #8DB4E2, align: right"]2013[/TD]
[TD="class: xl75, bgcolor: #8DB4E2, align: right"]44[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]8[/TD]
[TD="class: xl69, bgcolor: transparent"]6/1/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]1.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]9[/TD]
[TD="class: xl69, bgcolor: transparent"]6/4/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]2.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]10[/TD]
[TD="class: xl69, bgcolor: transparent"]6/5/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]8.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]11[/TD]
[TD="class: xl69, bgcolor: transparent"]6/6/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]4.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]12[/TD]
[TD="class: xl69, bgcolor: transparent"]6/11/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]4.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]13[/TD]
[TD="class: xl69, bgcolor: transparent"]6/11/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]16.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]14[/TD]
[TD="class: xl69, bgcolor: transparent"]6/14/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]2.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]15[/TD]
[TD="class: xl69, bgcolor: transparent"]6/14/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]2.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]16[/TD]
[TD="class: xl69, bgcolor: transparent"]6/14/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]2.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]17[/TD]
[TD="class: xl69, bgcolor: transparent"]6/24/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]1.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]18[/TD]
[TD="class: xl69, bgcolor: transparent"]6/24/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]4.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]19[/TD]
[TD="class: xl69, bgcolor: transparent"]6/24/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]2.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]20[/TD]
[TD="class: xl69, bgcolor: transparent"]6/25/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl76, bgcolor: #C4BD97"]2.00[/TD]
[TD="class: xl77, bgcolor: #C4BD97"] [/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]6[/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]2013[/TD]
[TD="class: xl77, bgcolor: #C4BD97, align: right"]50[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]21[/TD]
[TD="class: xl69, bgcolor: transparent"]7/2/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl78, bgcolor: #B7DEE8"]4.00[/TD]
[TD="class: xl79, bgcolor: #B7DEE8"] [/TD]
[TD="class: xl79, bgcolor: #B7DEE8, align: right"]7[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]22[/TD]
[TD="class: xl69, bgcolor: transparent"]7/2/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl78, bgcolor: #B7DEE8"]1.00[/TD]
[TD="class: xl79, bgcolor: #B7DEE8"] [/TD]
[TD="class: xl79, bgcolor: #B7DEE8, align: right"]7[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]23[/TD]
[TD="class: xl69, bgcolor: transparent"]7/11/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl78, bgcolor: #B7DEE8"]4.00[/TD]
[TD="class: xl79, bgcolor: #B7DEE8"] [/TD]
[TD="class: xl79, bgcolor: #B7DEE8, align: right"]7[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]24[/TD]
[TD="class: xl69, bgcolor: transparent"]7/11/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl78, bgcolor: #B7DEE8"]6.00[/TD]
[TD="class: xl79, bgcolor: #B7DEE8"] [/TD]
[TD="class: xl79, bgcolor: #B7DEE8, align: right"]7[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]25[/TD]
[TD="class: xl69, bgcolor: transparent"]7/16/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl78, bgcolor: #B7DEE8"]5.00[/TD]
[TD="class: xl79, bgcolor: #B7DEE8"] [/TD]
[TD="class: xl79, bgcolor: #B7DEE8, align: right"]7[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]26[/TD]
[TD="class: xl69, bgcolor: transparent"]7/18/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl78, bgcolor: #B7DEE8"]1.00[/TD]
[TD="class: xl79, bgcolor: #B7DEE8"] [/TD]
[TD="class: xl79, bgcolor: #B7DEE8, align: right"]7[/TD]
[TD="class: xl79, bgcolor: #B7DEE8, align: right"]2013[/TD]
[TD="class: xl79, bgcolor: #B7DEE8, align: right"]21[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]27[/TD]
[TD="class: xl69, bgcolor: transparent"]8/20/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl80, bgcolor: #D8E4BC"]1.00[/TD]
[TD="class: xl81, bgcolor: #D8E4BC"] [/TD]
[TD="class: xl81, bgcolor: #D8E4BC, align: right"]8[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]28[/TD]
[TD="class: xl69, bgcolor: transparent"]8/23/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl80, bgcolor: #D8E4BC"]1.00[/TD]
[TD="class: xl81, bgcolor: #D8E4BC"] [/TD]
[TD="class: xl81, bgcolor: #D8E4BC, align: right"]8[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]29[/TD]
[TD="class: xl69, bgcolor: transparent"]8/23/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl80, bgcolor: #D8E4BC"]4.00[/TD]
[TD="class: xl81, bgcolor: #D8E4BC"] [/TD]
[TD="class: xl81, bgcolor: #D8E4BC, align: right"]8[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]30[/TD]
[TD="class: xl69, bgcolor: transparent"]8/26/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl80, bgcolor: #D8E4BC"]2.00[/TD]
[TD="class: xl81, bgcolor: #D8E4BC"] [/TD]
[TD="class: xl81, bgcolor: #D8E4BC, align: right"]8[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]31[/TD]
[TD="class: xl69, bgcolor: transparent"]8/27/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl80, bgcolor: #D8E4BC"]2.00[/TD]
[TD="class: xl81, bgcolor: #D8E4BC"] [/TD]
[TD="class: xl81, bgcolor: #D8E4BC, align: right"]8[/TD]
[TD="class: xl66, bgcolor: transparent, align: right"]2013[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF"]32[/TD]
[TD="class: xl69, bgcolor: transparent"]8/30/2013[/TD]
[TD="class: xl70, width: 29, bgcolor: transparent"]TX[/TD]
[TD="class: xl66, bgcolor: transparent"] [/TD]
[TD="class: xl80, bgcolor: #D8E4BC"]4.00[/TD]
[TD="class: xl81, bgcolor: #D8E4BC"] [/TD]
[TD="class: xl81, bgcolor: #D8E4BC, align: right"]8[/TD]
[TD="class: xl81, bgcolor: #D8E4BC, align: right"]2013[/TD]
[TD="class: xl81, bgcolor: #D8E4BC, align: right"]14[/TD]
[/TR]
</tbody>[/TABLE]
 
Thanks for the compliments! I'll take a look at this later, but it seems trickier than the last part so I'm not so sure I'll be able to come up with anything. I'll give it a shot though hopefully I can figure it out.
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
You're new to VBA? Are you kidding me? That code is great! It did exactly what I needed. :)
If you're new to VBA, you're going to be amazing pretty soon. But I think you're amazing already, I have been working on this code all day and got no where.
You must have some other kind of code background, because that code you provided is great.

Thanks very much!

You don't have to take on this next step I need, but while I have your attention, I thought I'd ask.

The next thing I need is to compile this data onto another worksheet where the Item numbers are placed in Column A, the descriptions go into Column B, then the totals for each month would be dropped into the respective columns to the right. The second sheet would have headers for each column. Like this;

[TABLE="width: 799"]
<tbody>[TR]
[TD="class: xl67, width: 36, bgcolor: #D9D9D9"][/TD]
[TD="class: xl67, width: 64, bgcolor: #D9D9D9"]A[/TD]
[TD="class: xl67, width: 104, bgcolor: #D9D9D9"]B[/TD]
[TD="class: xl67, width: 64, bgcolor: #D9D9D9"]C[/TD]
[TD="class: xl67, width: 64, bgcolor: #D9D9D9"]D[/TD]
[TD="class: xl67, width: 64, bgcolor: #D9D9D9"]E[/TD]
[TD="class: xl67, width: 64, bgcolor: #D9D9D9"]F[/TD]
[TD="class: xl67, width: 77, bgcolor: #D9D9D9"]G[/TD]
[TD="class: xl67, width: 64, bgcolor: #D9D9D9"]H[/TD]
[TD="class: xl67, width: 72, bgcolor: #D9D9D9"]I[/TD]
[TD="class: xl67, width: 72, bgcolor: #D9D9D9"]J[/TD]
[TD="class: xl67, width: 64, bgcolor: #D9D9D9"]K[/TD]
[TD="class: xl67, width: 64, bgcolor: #D9D9D9"]L[/TD]
[TD="class: xl67, width: 64, bgcolor: #D9D9D9"]M[/TD]
[TD="class: xl67, width: 64, bgcolor: #D9D9D9"]N[/TD]
[TD="class: xl67, width: 64, bgcolor: #D9D9D9"]O[/TD]
[/TR]
[TR]
[TD="class: xl67, bgcolor: #D9D9D9"]1[/TD]
[TD="class: xl65, bgcolor: transparent"]Item #[/TD]
[TD="class: xl66, bgcolor: transparent"]Description[/TD]
[TD="class: xl68, bgcolor: transparent"]May-13[/TD]
[TD="class: xl68, bgcolor: transparent"]Jun-13[/TD]
[TD="class: xl68, bgcolor: transparent"]Jul-13[/TD]
[TD="class: xl68, bgcolor: transparent"]Aug-13[/TD]
[TD="class: xl68, bgcolor: transparent"]Sep-13[/TD]
[TD="class: xl68, bgcolor: transparent"]Oct-13[/TD]
[TD="class: xl68, bgcolor: transparent"]Nov-13[/TD]
[TD="class: xl68, bgcolor: transparent"]Dec-13[/TD]
[TD="class: xl68, bgcolor: transparent"]Jan-14[/TD]
[TD="class: xl68, bgcolor: transparent"]Feb-14[/TD]
[TD="class: xl68, bgcolor: transparent"]Mar-14[/TD]
[TD="class: xl68, bgcolor: transparent"]Apr-14[/TD]
[TD="class: xl68, bgcolor: transparent"]May-14[/TD]
[/TR]
[TR]
[TD="class: xl67, bgcolor: #D9D9D9"]2[/TD]
[TD="class: xl64, bgcolor: transparent, align: right"]10101[/TD]
[TD="class: xl63, bgcolor: transparent"]Item 1[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]44[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]50[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]21[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]14[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]45[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]7[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]19[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]30[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]31[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]36[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]42[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]82[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]16[/TD]
[/TR]
[TR]
[TD="class: xl67, bgcolor: #D9D9D9"]3[/TD]
[TD="class: xl64, bgcolor: transparent, align: right"]10102[/TD]
[TD="class: xl63, bgcolor: transparent"]Item 2[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]1[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]6[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]10[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]11[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]9[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]6[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]5[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]2[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]3[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]16[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]14[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]10[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]4[/TD]
[/TR]
[TR]
[TD="class: xl67, bgcolor: #D9D9D9"]4[/TD]
[TD="class: xl64, bgcolor: transparent, align: right"]10103[/TD]
[TD="class: xl63, bgcolor: transparent"]Item 3[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]2[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]7[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]1[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]2[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]0[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]1[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]0[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]2[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]0[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]6[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]5[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]1[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]0[/TD]
[/TR]
[TR]
[TD="class: xl67, bgcolor: #D9D9D9"]5[/TD]
[TD="class: xl64, bgcolor: transparent, align: right"]10104[/TD]
[TD="class: xl63, bgcolor: transparent"]Item 4[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]0[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]2[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]1[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]3[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]0[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]2[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]0[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]0[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]0[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]4[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]4[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]2[/TD]
[TD="class: xl63, bgcolor: transparent, align: right"]0[/TD]
[/TR]
</tbody>[/TABLE]


Since I don't have all of your data I don't know for sure but I think this might help

Code:
Sub Fixed2()

Dim MyRange As Range
Dim CopyRange As Range
Dim Cumulative As Double
Dim StartRow As Integer
Dim PasteColumn As Integer, PasteRow As Integer




'// CHANGE THESE VALUES TO FIT YOUR NEEDS //
StartRow = 5   '//Row where data begins
ItemNumber = 2 '//Number of Items
'//////////////////////////////////////////


StartRow = 5
Cumulative = 0
PasteColumn = 3
PasteRow = 2
j = 2 'Counter variable


Set MyRange = Range("F:H").SpecialCells(xlCellTypeConstants)
lastrow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row


For i = StartRow + 1 To lastrow + 1
    Cumulative = Cumulative + Range("D" & i - 1).Value
    If MyRange(i, 1) <> MyRange(i - 1, 1) Then
        Set CopyRange = MyRange(i - 1, 1).Offset(, 2)
        CopyRange.Value = Cumulative
        Cumulative = 0
    End If
Next i


'Copies Description
Range("C1:C5000").SpecialCells(xlCellTypeConstants).Copy ( _
        Worksheets(2).Range("B1"))


'Copies Item Numbers
Range("C1:C5000").SpecialCells(xlCellTypeConstants).Offset(0, -2).Copy ( _
        Worksheets(2).Range("A1"))


'Copies Numbers
For j = 1 To ItemNumber
    StartCopyRow = Cells.Find("Item " & (j), SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    
    If j = ItemNumber Then
        EndCopyRow = lastrow
    Else
        EndCopyRow = Cells.Find("Item " & (j + 1), SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    End If
        
    Range("H" & StartCopyRow, "H" & EndCopyRow).SpecialCells(xlCellTypeConstants).Copy
    Worksheets(2).Range("C" & j + 1).PasteSpecial Transpose:=True
Next j




End Sub

Just change the ItemNumber and StartRow values at the top. On the last macro it was StartRow + 1, I made a change so that's not needed anymore. Now, it's just wherever the data starts which in this case appears to be row 5. I also made the assumption that the second sheet in your workbook is where the data is summarized if that's not the case just change every instance of Worksheets(2) to Worksheets(x). I hope this works!
 
Upvote 0
RadioME,
This is really good stuff. Again, you are amazing.
Your entire code works, and pastes the data to the second worksheet with the sample data.

But I'm having a problem with this line;
Code:
For j = 1 To ItemNumber
    StartCopyRow = Cells.Find("Item " & (j), SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row

This line of code is searching for the item description (which are Item 1, Item 2, Item 3, etc) in the sample screen shots above. The code doesn't work with the real descriptions. Could you adjust this section so that the code searches for the item number, then transposes the relevant monthly data to sheet2?

If you are willing, I would not mind sending the actual file to you since files can't be attached in this forum.

Thanks,
Jim
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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