Formula in a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am running a macro in a workbook that finds the first empty row in a range,
then I have the pointer move to the next column (L) and up one. I need to
put a formula in that cell "=sum(K1:K45)". When I run the macro I am getting
a result in the cell "#NAME?" and the formula shows as "=SUM('K1':'K45')"

Can anyone help on how to correctly input the formula in the macro.

Thanks
Linda
 
Those apostrophes around the cell addresses shouldn't be there. It would
help if you showed us the code you are using to assign the formula.

Rick
 
In your code you should have something like this if your formula is in K46:

Range("K46").FormulaR1C1 = "=SUM(R[-45]C:R[-1]C)"

Note that this is a Row Column Reference.
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.
 
Hi Linda -

After your code moves the pointer to the proper cell, run this statement (it
uses the A1-style reference):

Selection.Formula = "=sum(K1:K45)"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top