VBA code to change the Sheet 1 data as per Sheet 2

motherindia

Board Regular
Joined
Oct 15, 2015
Messages
218
Hello Sir,

I have 2 sheets. Sheet 1 contains 5 columns and Cust No is unique id. I need to combine the amount based on Cust No and also get the latest value for Type /1002 against SAP Period .

I need to automate to do this in VBA.
[TABLE="width: 624"]
<tbody>[TR]
[TD="colspan: 2"]Input on Sheet 1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Cust No[/TD]
[TD]Name[/TD]
[TD]SAP Period[/TD]
[TD]Type[/TD]
[TD]Amt[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]A[/TD]
[TD]201005[/TD]
[TD]/1001[/TD]
[TD]-30,637.00[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]B[/TD]
[TD]200804[/TD]
[TD]/1001[/TD]
[TD]-1,974.00[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]B[/TD]
[TD]200805[/TD]
[TD]/1001[/TD]
[TD]1,000.00[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]C[/TD]
[TD]200810[/TD]
[TD]/1001[/TD]
[TD]-8,606.00[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]D[/TD]
[TD]200802[/TD]
[TD]/1001[/TD]
[TD]-2,074.00[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]D[/TD]
[TD]200803[/TD]
[TD]/1002[/TD]
[TD]-10,721.00[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]D[/TD]
[TD]200805[/TD]
[TD]/1002[/TD]
[TD]-2,531.00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"]Output on Sheet 2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Cust No[/TD]
[TD][/TD]
[TD]Total (/1001+/1002)[/TD]
[TD]//1002[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD]-30,637.00[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]-974.00[/TD]
[TD]1,000.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD]-8,606.00[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD]-15,236.00[/TD]
[TD]-2,531.00
[/TD]
[/TR]
</tbody>[/TABLE]

Regards,
motherindia
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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