VBA Code for creating a formula for adding specific values (=IF(A2:A10)=B2,B2,C2))

Feroz90

Board Regular
Joined
Apr 25, 2019
Messages
52
Hi All,

In the below example, I want to add each days splitted amount in Amt 3 and reconcile with Amt 1 & Amt 2, say for example, For Monday, if we add first 4 rows in Amt 3, we get 2000 which is in Amt 2 and if we add next 3 rows of Monday , we get 1000 which is in Amt 1. Anyone's help with any VBA code will be appreciated.

DaysAmt 1Amt 2Amt 3TotalExample
Monday100020005002000500 + 500 + 500 + 500
Monday100020005002000500 + 500 + 500 + 500
Monday100020005002000500 + 500 + 500 + 500
Monday100020005002000500 + 500 + 500 + 500
Monday100020002501000500 + 250 + 250
Monday100020002501000500 + 250 + 250
Monday100020005001000500 + 250 + 250
Tuesday290011007502900750 + 750 + 500 + 450 +450
Tuesday290011007502900750 + 750 + 500 + 450 +450
Tuesday290011006001100600 + 500
Tuesday290011005001100600 + 500
Tuesday290011005002900750 + 750 + 500 + 450 +450
Tuesday290011004502900750 + 750 + 500 + 450 +450
Tuesday290011004502900750 + 750 + 500 + 450 +450
Wednesday150025007501500750 + 750
Wednesday150025007501500750 + 750
Wednesday15002500100025001000 + 1000 + 250 +250
Wednesday15002500100025001000 + 1000 + 250 +250
Wednesday1500250025025001000 + 1000 + 250 +250
Wednesday1500250025025001000 + 1000 + 250 +250
Thursday22502750100022501000 + 250 +1000
Thursday225027507502750750 + 2000
Thursday2250275025022501000 + 250 +1000
Thursday2250275020002750750 + 2000
Thursday22502750100022501000 + 250 +1000
Friday845015504508450450 + 2000 + 3000 + 1000 + 2000
Friday845015505501550550 + 1000
Friday8450155020008450450 + 2000 + 3000 + 1000 + 2000
Friday8450155030008450450 + 2000 + 3000 + 1000 + 2000
Friday8450155010001550550 + 1000
Friday8450155010008450450 + 2000 + 3000 + 1000 + 2000
Friday8450155020008450450 + 2000 + 3000 + 1000 + 2000

<colgroup><col><col span="4"><col></colgroup><tbody>
</tbody>

Thanks you in advance
 
Have you tried using Excel Solver?
That is the only non-VBA method I am aware of.
If you are unsure on how to use it, just Google it. There are tons of tutorials and demos to be found.
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Nope, we can able to do it for only one solution, not for list of numbers. That is why I need to create a new one.
 
Upvote 0
When you say "list of numbers", are you referring to the various values in column D that add up to the value in the first row of column C, or are you referring to something else?
 
Upvote 0
It sounds like you are talking about something like multiple simultaneous "Solver-like" sitations. I do not know of any "quick and easy" ways of doing that. I think you may be wading into some pretty complex VBA code, one that it might not be reasonable to expect to be solved via free help. You may have to enlist the help of some Consulting Services (https://www.mrexcel.com/consulting-services/).
 
Upvote 0
Re: VBA Code for adding specific values in two columns

There does not seem to be consistency in how rows are combined to make their column 3 values add to give values in columns 1 & 2.
Please recreate your example using unique numbers in column 3.
What is the rule for determining which rows are combined to create the values in column 1
What is the rule for determining which rows are combined to create the values in column 2
 
Upvote 0
Re: VBA Code for adding specific values in two columns

I have merged your two threads together, since they were on the same question.

In the future, please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread. Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).
 
Upvote 0
Re: VBA Code for adding specific values in two columns

Hi,

Thank you for your response.

Please find below the example, each day have different cash transactions, but every day's cash balance are the same, so I just want to know which are all transactions are debited and which are all credited.

DaysCash in BankCash in HandCash Transactions
Monday1100900750
Monday1100900150
Monday1100900800
Monday1100900300
Tuesday450550200
Tuesday450550250
Tuesday450550325
Tuesday450550225
Wednesday385115150
Wednesday38511550
Wednesday385115115
Wednesday385115185


<colgroup><col><col><col><col></colgroup><tbody>
</tbody>

Thanks in advance
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,956
Members
449,096
Latest member
Anshu121

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