You have some data values typed on column A starting from cell A1. You have to create a macro that cumulatively sums the last ‘n’ values provided in column A starting from current row and write the result in corresponding cell of column B. For example, if n=5, then in cell B5 you have to provide sum of values from cell A1 to A5. Similarly in cell B7, the sub should write the sum of values from cell A3 to A7. Essentially the macro shall be providing the sum in cell B5 onwards to include all last ‘n’ values in column A. Unless the number is Column A is ‘5’, in that case, ignore it and do not add it to the sum. Take the input of ‘n’ from the user and make a ‘button’ to launch the macro.
Please refer to the tab “sum” in the file “Final.xlsx”final.xlsx