I want to sum a column of data starting from the cell above up to n cells above. n is given in a variable called custnum. This doesn't work:
ActiveCell.FormulaR1C1 = "=SUM(r[-custnum]C:R[-1]C)"
Hope someone can help!
Thanks
Sue
I want to sum a column of data starting from the cell above up to n cells above. n is given in a variable called custnum. This doesn't work:
ActiveCell.FormulaR1C1 = "=SUM(r[-custnum]C:R[-1]C)"
Hope someone can help!
Thanks
Sue
Try using -
ActiveCell.FormulaR1C1 = "=SUM(R[-" & custnum & "]C:R[-1]C)" where custnum variable would specify the number of cells to be summed above.
The variable custnum should not be within double quotes as it would then be considered as a string and not a variable.
Happy to Help
How to upload excel workbooks at this forum - http://www.excelforum.com/the-water-...his-forum.html
"I don't get things easily, so please be precise and elaborate"
If someone's post has helped you, thank by clicking on "Add Reputation" below the post.
If your query is resolved please mark the thread as "Solved" from the "Thread Tools" above.
Sourabh
Many thanks Sourab, it worked fine. Sometimes I think VBA isn't intuitive!
Best wishes
Sue
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks