Forum Discussion

jakebradleey's avatar
jakebradleey
Copper Contributor
Jan 30, 2020

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

  • Charla74's avatar
    Charla74
    Iron Contributor
    If D15 simply has to show what is in D14, just enter the formula in D15 as follows:
    =$D$14
    • jakebradleey's avatar
      jakebradleey
      Copper Contributor
      No unfortunately not, I mean I want the figures in D15 to accumulate but the only source is a changing value of D14
      • Charla74's avatar
        Charla74
        Iron Contributor
        Oh, 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).