VBA for adding cells then posting them into a unique cell

Mrnewb

New Member
Joined
Oct 7, 2013
Messages
13
Hi, and thanks in advance for any help.

I need a code that will look an ID in columb A then add all the same ID's assosated values in columb C, it must then transfere this data to a second sheet and lookup the assosiated date and ID a past into the correct cell. "sounds easy"
Sheet1
[TABLE="width: 317"]
<colgroup><col width="112" style="width: 84pt; mso-width-source: userset; mso-width-alt: 4096;"> <col width="98" style="width: 74pt; mso-width-source: userset; mso-width-alt: 3584;"> <col width="64" style="width: 48pt;"> <col width="81" style="width: 61pt; mso-width-source: userset; mso-width-alt: 2962;"> <col width="67" style="width: 50pt; mso-width-source: userset; mso-width-alt: 2450;"> <tbody>[TR]
[TD="width: 112, bgcolor: transparent"]Document Number[/TD]
[TD="width: 98, bgcolor: transparent"]2nd Item Number[/TD]
[TD="width: 64, bgcolor: transparent"]Trans QTY[/TD]
[TD="width: 81, bgcolor: transparent"]Order Date[/TD]
[TD="width: 67, bgcolor: transparent"]Plan Fmly[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1154663[/TD]
[TD="bgcolor: transparent"]01/6029H[/TD]
[TD="bgcolor: transparent"]300[/TD]
[TD="bgcolor: transparent"]03/12/2018[/TD]
[TD="bgcolor: transparent"]248[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1154664[/TD]
[TD="bgcolor: transparent"]01/6059H[/TD]
[TD="bgcolor: transparent"]40[/TD]
[TD="bgcolor: transparent"]03/12/2018[/TD]
[TD="bgcolor: transparent"]248[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1154664[/TD]
[TD="bgcolor: transparent"]01/6059H[/TD]
[TD="bgcolor: transparent"]100[/TD]
[TD="bgcolor: transparent"]03/12/2018[/TD]
[TD="bgcolor: transparent"]248[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1154664[/TD]
[TD="bgcolor: transparent"]01/6059H[/TD]
[TD="bgcolor: transparent"]100[/TD]
[TD="bgcolor: transparent"]03/12/2018[/TD]
[TD="bgcolor: transparent"]248[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1150219[/TD]
[TD="bgcolor: transparent"]01/6224H[/TD]
[TD="bgcolor: transparent"]64[/TD]
[TD="bgcolor: transparent"]03/12/2018[/TD]
[TD="bgcolor: transparent"]248
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1150219[/TD]
[TD="bgcolor: transparent"]01/6224H[/TD]
[TD="bgcolor: transparent"]64[/TD]
[TD="bgcolor: transparent"]03/12/2018[/TD]
[TD="bgcolor: transparent"]248[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1150219[/TD]
[TD="bgcolor: transparent"]01/6224H[/TD]
[TD="bgcolor: transparent"]64[/TD]
[TD="bgcolor: transparent"]03/12/2018[/TD]
[TD="bgcolor: transparent"]248[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1150219[/TD]
[TD="bgcolor: transparent"]01/6224H[/TD]
[TD="bgcolor: transparent"]64[/TD]
[TD="bgcolor: transparent"]03/12/2018[/TD]
[TD="bgcolor: transparent"]248[/TD]
[/TR]
</tbody>[/TABLE]

Sheet 2

[TABLE="width: 330"]
<colgroup><col width="112" style="width: 84pt; mso-width-source: userset; mso-width-alt: 4096;"> <col width="80" style="width: 60pt; mso-width-source: userset; mso-width-alt: 2925;"> <col width="82" style="width: 62pt; mso-width-source: userset; mso-width-alt: 2998;" span="3"> <tbody>[TR]
[TD="width: 112, bgcolor: #BFBFBF"]Works order
[/TD]
[TD="width: 80, bgcolor: #BFBFBF"]Component Number[/TD]
[TD="width: 82, bgcolor: #BFBFBF"]Monday
[/TD]
[TD="width: 82, bgcolor: #BFBFBF"]Tuesday[/TD]
[TD="width: 82, bgcolor: #BFBFBF"]Wednesday[/TD]
[/TR]
[TR]
[TD="bgcolor: #BFBFBF"]03/12/2018[/TD]
[TD="bgcolor: #BFBFBF"]04/12/2018[/TD]
[TD="bgcolor: #BFBFBF"]05/12/2018[/TD]
[/TR]
[TR]
[TD="bgcolor: #BFBFBF"]PDN[/TD]
[TD="bgcolor: #BFBFBF"]PDN[/TD]
[TD="bgcolor: #BFBFBF"]PDN[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1165904[/TD]
[TD="bgcolor: transparent"]174/600[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1155200[/TD]
[TD="bgcolor: transparent"]13/5292[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1155135[/TD]
[TD="bgcolor: transparent"]13/5057[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1156552[/TD]
[TD="bgcolor: transparent"]13/7113[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]1155205[/TD]
[TD="bgcolor: transparent"]13/5319[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0[/TD]
[TD="bgcolor: transparent"]0
[/TD]
[/TR]
</tbody>[/TABLE]



IE it will take ID (1154664 ) in sheet 1 Add the "Trans Qty" together for that ID only, the take that value and past it under Mondays 03/12/2018 (Must use the assosiated date to chos the columb) columb in sheet 2 in the row marked (1154664).

Is this possible? I tried but nt evenknow where to start on this one?

Thanks again .
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
It's a little hard to see exactly what you want, since your example doesn't have expected results, and I can't figure out where the dates are, but you should be able to use SUMIFS. In your example above on the second sheet in C4, try this:

=SUMIFS(Sheet1!$C:$C,Sheet1!$A:$A,$A4,Sheet1!$D:$D,C$2)

The A4 is the ID which will match on the A column on Sheet1, and the C$2 is the date that should match the D column on Sheet1. You should be able to drag the formula down and across as needed.
 
Last edited:
Upvote 0
Thank you Eric W, I have changed things to make your formula work, Is there a way to do the same thing with VBA so that I can delete the original data but keep the "Calculated" data?
 
Upvote 0
Sure, you can do that. I'd need to know what your worksheet looks like now, since you say you changed things. You may want to try to just copy the Calculated data, and do a Paste Special/Values to keep it.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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