I am having a problem figuring out how to get the R1C1 forumula to accept a changing value. What I am trying to do is get a macro to calculate the average value of a column on a spreadsheet. However the number of columns changes depending on the spreadsheet. So I want it to count the columns and based on the number of columns counted, calculate the average for as many columns are on the spreadsheet.
How could I get VBA to accept columncount as a numerical value for the "R1C1Formula =" ?![]()
Sub paste() ActiveCell.FormulaR1C1 = "=AVERAGE(R[-6]C[(-columncount)]:RC[(-columncount)]))" ActiveCell.Offset(0, 1).Range("A1").Select End Sub
Bookmarks