VBA - changing references for formula based on a given criteria

bob1987

New Member
Joined
Jul 18, 2017
Messages
1
Dear All,
I am struggling with this issue for a while.
I have to build a macro that changes formulas references according to a given set of criteria (basically moving the reference if it refers to external factor and staying at the previous year if it internal)
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Type[/TD]
[TD]name[/TD]
[TD]2016[/TD]
[TD]2017[/TD]
[TD]2018[/TD]
[TD]2019[/TD]
[TD]2020[/TD]
[TD]2021[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]external[/TD]
[TD]price[/TD]
[TD]100[/TD]
[TD]101[/TD]
[TD]95[/TD]
[TD]98[/TD]
[TD]78[/TD]
[TD]58[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]internal[/TD]
[TD]discount[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]4[/TD]
[TD]2[/TD]
[TD]-1[/TD]
[TD]-5[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]internal[/TD]
[TD]volume[/TD]
[TD]10[/TD]
[TD]11[/TD]
[TD]10,5[/TD]
[TD]11[/TD]
[TD]10[/TD]
[TD]11[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD]formula[/TD]
[TD]=(C2-C3)*C4[/TD]
[TD]=(C2-D3)*D4[/TD]
[TD]=(D2-E3)*E4[/TD]
[TD]=(E2-F3)*F4[/TD]
[TD]=(F2-G3)*G4[/TD]
[TD]=(G2-H3)*H4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Unfortunately there are no standard formulas that are calculated.
I would like only to insert the first formula (in C6) and then build a macro that extend it. I know that it is possible but I cannot get around it :(:(
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,226,694
Messages
6,192,473
Members
453,726
Latest member
JoeH57

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