kyddrivers
Board Regular
- Joined
- Mar 22, 2013
- Messages
- 64
- Office Version
- 365
- Platform
- Windows
I am looking to create a macro that will prompt the user for a number. This number will represent the number of columns to used to create the average formula.
Here is where I am at so far...
So far, I am getting an application defined or object defined error on the formula line.
Boils down to this...need to get the formula to read the user entered variable in averange to inserted into the formula
Let me know if you have any questions.
Thanks for your help in advance.
Here is where I am at so far...
Code:
Sub ave_test()
Dim averange As Integer
showavebox:
averange = InputBox("Enter the number of weeks to calculate pattern and click OK", "Thanks")
Range("A3").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-2]C[2]:R[-2]C[averange])"
Range("A4").Select
End Sub
So far, I am getting an application defined or object defined error on the formula line.
Boils down to this...need to get the formula to read the user entered variable in averange to inserted into the formula
Let me know if you have any questions.
Thanks for your help in advance.