Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Formula in a macro

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Formula in a macro

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


"mathel" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Formula in a macro

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.




"Rick Rothstein (MVP - VB)" wrote:

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


"mathel" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Formula in a macro

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)"

------
Jay

"mathel" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with the macro or with the formula Igneshwara reddy[_2_] Excel Worksheet Functions 6 March 22nd 07 09:16 PM
Formula in macro causes macro to fail KCK Excel Programming 2 February 8th 07 08:47 PM
macro or formula CMD Excel Programming 2 October 4th 06 08:58 PM
Formula expected end of statement error, typing formula into cell as part of VBA macro [email protected] Excel Programming 1 July 20th 06 07:58 PM
Formula & Macro nik_gujarathi[_7_] Excel Programming 0 May 26th 06 09:05 PM


All times are GMT +1. The time now is 05:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"