VBA code / Loop function to match amounts

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello experts,
The amounts in column B and C are entered using formula '=RANDBETWEEN(10,90*10)*10. I have to match actual amount with the total as per calculation. The difference must show zero(0). I select the amounts from cell B50 upwards till I get the nearest value of the difference and delete it. Then I enter the difference amount in the last empty column in column B to get zero. I do this for every column in the sheet. There are around 30 columns in each sheet and has 12 months sheet data to be matched. It takes a lot of time. I was hoping whether, if this would be possible with the help of a code, it will save a lot of time.

Code to match amounts.xlsx
ABCDEFG
1Apr-2001-04-202002-04-2020Apr-2001-04-202002-04-2020
27770454077704540
3Original Data82705590Matched Data82705590
46400511064005110
558057405805740
64570321045703210
743605004360500
843208504320850
93670545036705450
104280500042805000
113180243031802430
1278303207830320
132770248027702480
146230830062308300
1528046902804690
166760361067603610
1789005008900500
1899043409904340
1973104107310410
204060646040606460
2111017601101760
221570231015702310
233080460030804600
2435070403507040
2579501207950120
26113056803105680
27677031203120
28873017901790
29159084508450
30352032901500
3114607650
3222501910
3321304570
3468804330
3514804530
3661903760
373605610
3887601530
3911804520
4085308740
4177606000
4280407350
4363302210
4442301990
4570508180
4615707350
4771001570
4818907200
4943302950
504103940
51
52Total As per Calculation2,15,260.002,03,580.00Total As per Calculation1,05,900.001,05,900.00
53Actual Amount1,05,900.001,05,900.00Actual Amount1,05,900.001,05,900.00
54Difference1,09,360.0097,680.00Difference--
55207040.000.00
56
April workings
Cell Formulas
RangeFormula
B1,F1B1=A1
C1,G1C1=B1+1
F52:G52,B52:C52B52=SUM(B2:B50)
F54:G54,B54:C54B54=B52-B53
A55,E55A55=SUM(B54:C54)
 
Thanks Mackc577 for helping to solve this.
Of course, it's a fairly simple program, but the challenge comes from making my understanding match what you are hoping to achieve. I'm glad I was able to accomplish that this time.
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,215,014
Messages
6,122,697
Members
449,092
Latest member
snoom82

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