Excel VBA Insert Formula Into Cell using a variable

Hello Experts,

This should be easy but I can not get the following to work.

I'm entering a formula into a cell using a variable in the formula.  What I need to do is insert a formula that gives the average of C2 to N , where N is an entry the user puts in.  Soooo, the formula that gets posted into F1 is: Range("F1").Formula = "=Average("$C$3" ":" "$C,$N" )"  I am fairly new to Excel VBA.  Thanks!!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Range("F1").Formula = "=Average("$C$3:$C" & N)
Martin LissOlder than dirtCommented:
BTW you said C2 but your example shows C3, so I went with that.
Saqib Husain, SyedEngineerCommented:

Range("F1").Formula = "=Average($C$3:$C$" & N & ")"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

CompTech810Author Commented:
Thanks for the quick response!

Martin I tried your formula and received an error at the first $, "Invalid Character"

Saqib I tried your formula and this is the result in F1:  =AVERAGE("$C$2:$C$"&n )
Saqib Husain, SyedEngineerCommented:
I have modified my formula. Give it a go again.
CompTech810Author Commented:
Saqib that worked!!  Thanks!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.