Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Error when using macro to write formula to cell

When typed directly in cell L11, this formula does what I want:
=IF(E11<0.25,"",E11-TIME(0,16,0))

When I go to the Immediate Window and type ? range ("L11").FormulaR1C1, the
following is returned: =IF(RC[-7]<0.25,"",RC[-7]-TIME(0,16,0))

So I tried to create a procedure using that -

Range("L11").Activate
ActiveCell.FormulaR1C1 = "=IF(RC[-7]<0.25,"",RC[-7]-TIME(0,16,0))"

.... and get the error "Run-time error '1004': Application-defined or
object-defined error"

Can anyone tell me what I am doing wrong?

TIA, Patti



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Error when using macro to write formula to cell

Hi
try
ActiveCell.FormulaR1C1 = "=IF(RC[-7]<0.25,"""",RC[-7]-TIME(0,16,0))"

--
Regards
Frank Kabel
Frankfurt, Germany


Patti wrote:
When typed directly in cell L11, this formula does what I want:
=IF(E11<0.25,"",E11-TIME(0,16,0))

When I go to the Immediate Window and type ? range
("L11").FormulaR1C1, the following is returned:
=IF(RC[-7]<0.25,"",RC[-7]-TIME(0,16,0))

So I tried to create a procedure using that -

Range("L11").Activate
ActiveCell.FormulaR1C1 = "=IF(RC[-7]<0.25,"",RC[-7]-TIME(0,16,0))"

... and get the error "Run-time error '1004': Application-defined or
object-defined error"

Can anyone tell me what I am doing wrong?

TIA, Patti


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Error when using macro to write formula to cell

Patti,

Try
ActiveCell.FormulaR1C1 =
"=IF(RC[-7]<0.25,"""",RC[-7]-TIME(0,16,0))"

Note that additional quotes inside the formula.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Patti" wrote in message
...
When typed directly in cell L11, this formula does what I want:
=IF(E11<0.25,"",E11-TIME(0,16,0))

When I go to the Immediate Window and type ? range

("L11").FormulaR1C1, the
following is returned: =IF(RC[-7]<0.25,"",RC[-7]-TIME(0,16,0))

So I tried to create a procedure using that -

Range("L11").Activate
ActiveCell.FormulaR1C1 =

"=IF(RC[-7]<0.25,"",RC[-7]-TIME(0,16,0))"

... and get the error "Run-time error '1004':

Application-defined or
object-defined error"

Can anyone tell me what I am doing wrong?

TIA, Patti





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Error when using macro to write formula to cell

Frank, that extra set of quotes did the trick. Thank you very much - I
never would have come up with that on my own!

Patti


"Frank Kabel" wrote in message
...
Hi
try
ActiveCell.FormulaR1C1 = "=IF(RC[-7]<0.25,"""",RC[-7]-TIME(0,16,0))"

--
Regards
Frank Kabel
Frankfurt, Germany


Patti wrote:
When typed directly in cell L11, this formula does what I want:
=IF(E11<0.25,"",E11-TIME(0,16,0))

When I go to the Immediate Window and type ? range
("L11").FormulaR1C1, the following is returned:
=IF(RC[-7]<0.25,"",RC[-7]-TIME(0,16,0))

So I tried to create a procedure using that -

Range("L11").Activate
ActiveCell.FormulaR1C1 = "=IF(RC[-7]<0.25,"",RC[-7]-TIME(0,16,0))"

... and get the error "Run-time error '1004': Application-defined or
object-defined error"

Can anyone tell me what I am doing wrong?

TIA, Patti




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
Use macro to write formula nc Excel Discussion (Misc queries) 1 July 5th 09 07:13 AM
How do I write an Excel macro when the cell range changes weekly? AT Excel Discussion (Misc queries) 3 December 12th 07 11:46 PM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
How to write a formula that will prevent appearance ERROR MESSAGE Huriiii Excel Worksheet Functions 1 June 22nd 05 12:45 AM
Question: Cell formula or macro to write result of one cell to another cell Frederik Romanov Excel Programming 1 July 8th 03 03:03 PM


All times are GMT +1. The time now is 04:32 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"