Forum Discussion
jakebradleey
Jan 30, 2020Copper Contributor
Excel Macro
Hello I’m using excel and have created a pricing matrix for my product, I’m trying to create a macro that adds up the prices generated currently cell D14 has the end cost and I want D15 to add the figure of D14 with the click of a button (So say the product comes out at £5, D14 currently says £5, D15 currently says £0, click button, D15 changes to £5, I change a variable, D14 now says £10, click button, D15 changes to £15) sorry that’s the best I can explain it..
3 Replies
- Charla74Iron ContributorIf D15 simply has to show what is in D14, just enter the formula in D15 as follows:
=$D$14- jakebradleeyCopper ContributorNo unfortunately not, I mean I want the figures in D15 to accumulate but the only source is a changing value of D14
- Charla74Iron ContributorOh, ok, now I get it.
This could be done in VBA where the code behind your ‘Add to Price’ button would simply add a formula in D15...
In VBA editor, add the following code
Sub AddToGTtl ()
Range(“D15”).formula = Range(“D14”).value + Range(“D15”).value
End Sub
Sub ClrGTtl ()
Range(“D15”).clear
End Sub
You can then add a button and assign the macros (first one adds the sub total into the grand total, second one clears the grand total so you can start a new one).