IF, Then Deduct Macro

ktoon

New Member
Joined
Feb 5, 2015
Messages
30
Hi All,

I have an extremely difficult issue that I am trying to solve by using a Macro, but I'm not sure if this is beyond Macro capabilities!

Currently, I have a macro for the below data, if Column B = 1 or 4 then replace data in Column C with Column D - then delete all of column D. This works fine.



ABCD
70912442
70942442
70920142
70991242
71120142
71193642
71213642
71243642
71220142
71291242

<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>
</tbody>

However, now what I am trying to do brings in an IF statement also based on Column A, in which is a unique ID tied to a person.

So, on a per person basis (ID in column A), after the macro I stated above has run, would deduct the value from column C, where the ID = 9 in Column B FROM the values in Column C where the ID = 1 or 4 in Column B

To use Column A ID 709 as an example, this is how the output should like once complete:

ABC
709130
709430
709201
709912

<tbody>
</tbody>

And in the Example of person 711 above, who has no 1 or 4 ID in Column B associated, no deductions would take place for them (since the deducted ID's are not present for that person) and it would look exactly as it does above so no changes necessary.

Hopefully some genius out there can help me figure this one out I've:confused: been at it hours but it's far too confusing!
 
Hi Hiker,

No, I must admit I did not try your solution - I couldn't identify in the code where I could manually change the affected ID's. I originally asked for the deduction to only occur for ID's with 1 and 4, but I actually need an alternative that performs the same function except against 1, 4 and 5 (as in the Macro I posted).

Although it appears the Macro I posted works fine (provided by Steve), do you believe that there is a benefit to your code instead of this? (not trying to be insulting/rude if I sound that way at all)

ktoon,

If you look at your raw data screenshot, and, your results screenshot, they are the same as my screenshots?????

It would only be fair to come to a final conclusion if you were to try all posted macros.
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,215,621
Messages
6,125,884
Members
449,268
Latest member
sGraham24

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