LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default VBA formula question

Yes, you can, but sometimes it takes a lot of code to emulate a worksheet
function. For example, in the case you gave, you'd have to test for 0 in M13
(R4C13) and make the decision in your code whether to put up "Data?" or the
result.

One trick you can use would be to achieve the result would be to add a line
of code right after the one where you've used your .FormulaR1C1 = ...
statement
cell.offset(,-1).Formula = cell.offset(,-1).Value
would take the result of the formula you just put into a cell and replace
the formula with that result/value. Of course the tradeoff here is that it
takes more time to process than just building the formula, or possibly more
time than having the calculation done in code.

"Roger on Excel" wrote:

I use the following type of code to place formulas in cells :

For Each cell In Range("A1:A2")

cell.Offset(, 1).FormulaR1C1 = "=RC[10]&RC[8]&RC[15]"
'Equiv
cell.Offset(, -1).FormulaR1C1 =
"=IF(ISERROR(RC[5]/r4c13),""Data?"",RC[3]/r4c13)"
Next

This works fine, however my question is whether one can perform the
calculations in the code and just place the result into the cells?

I guess this may require learning a whole new syntax for coding the
equations, but I was wondering if someone could give me some pointers?

Many Thanks,

Roger

 
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
Newbie Formula Question - how to get formula to repeat in each subsequent row? [email protected] New Users to Excel 2 January 10th 10 05:02 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
I get error with "ROWS" in the formula - nested formula question Marie J-son Excel Worksheet Functions 0 January 4th 06 01:55 PM
Formula Question shadrach Excel Discussion (Misc queries) 1 May 10th 05 08:25 AM
Formula Question...PLEASE PLEASE help! Anant Excel Worksheet Functions 3 January 16th 05 01:48 PM


All times are GMT +1. The time now is 06:32 PM.

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

About Us

"It's about Microsoft Excel"