Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Why does the Formula in VBA not calculate

I have some code that plugs in a formula. The formula is not calculating
and instead is showing up as the code itself.

This is the formula:
ActiveCell.FormulaR1C1 = _

"=IF(OR(RC[-2]=Cond1,RC[-2]=Cond2,RC[-2]=Cond3,RC[-2]=Cond4,RC[-2]=Cond5,RC[-2]=Cond6,RC[-2]=Cond7,RC[-2]=Cond8,RC[-2]=Cond9,RC[-2]=Cond10,RC[-2]=Cond11,RC[-2]=Cond12,RC[-2]=Cond13),""C&I"",RC[1])"

Once the code runs, the cells show this:
=IF(OR(RC[-2]=Cond1,RC[-2]=Cond2,RC[-2]=Cond3,RC[-2]=Cond4,RC[-2]=Cond5,RC[-2]=Cond6,RC[-2]=Cond7,RC[-2]=Cond8,RC[-2]=Cond9,RC[-2]=Cond10,RC[-2]=Cond11,RC[-2]=Cond12,RC[-2]=Cond13),"C&I",RC[1])


instead of the results. Note: COND1, cond2, cond3, cond4, etc. are a named
range in another sheet. Can anyone please tell me why the code is not
calculating? As a side note....the cells are formatted as text after code
run....and general before the code runs.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Why does the Formula in VBA not calculate

I'd make sure that the activecell is formatted as General before you plop in the
formula.

with activecell
.numberformat = "General"
.formular1c1 = "=...."
end with



petedacook wrote:

I have some code that plugs in a formula. The formula is not calculating
and instead is showing up as the code itself.

This is the formula:
ActiveCell.FormulaR1C1 = _

"=IF(OR(RC[-2]=Cond1,RC[-2]=Cond2,RC[-2]=Cond3,RC[-2]=Cond4,RC[-2]=Cond5,RC[-2]=Cond6,RC[-2]=Cond7,RC[-2]=Cond8,RC[-2]=Cond9,RC[-2]=Cond10,RC[-2]=Cond11,RC[-2]=Cond12,RC[-2]=Cond13),""C&I"",RC[1])"

Once the code runs, the cells show this:
=IF(OR(RC[-2]=Cond1,RC[-2]=Cond2,RC[-2]=Cond3,RC[-2]=Cond4,RC[-2]=Cond5,RC[-2]=Cond6,RC[-2]=Cond7,RC[-2]=Cond8,RC[-2]=Cond9,RC[-2]=Cond10,RC[-2]=Cond11,RC[-2]=Cond12,RC[-2]=Cond13),"C&I",RC[1])

instead of the results. Note: COND1, cond2, cond3, cond4, etc. are a named
range in another sheet. Can anyone please tell me why the code is not
calculating? As a side note....the cells are formatted as text after code
run....and general before the code runs.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Why does the Formula in VBA not calculate


are you looking for:
Activecell.FormulaR1C1="=IF(OR(RC[-2]=Cond1,RC[-2]=Cond2,RC[-2]=Cond3,RC[-2]=Cond4,RC[-2]=Cond5,RC[-2]=Cond6,RC[-2]=Cond7,RC[-2]=Cond8,RC[-2]=Cond9,RC[-2]=Cond10,RC[-2]=Cond11,RC[-2]=Cond12,RC[-2]=Cond13),"&
"""C&I""" & ",RC[1])"

?

petedacook;435310 Wrote:
I have some code that plugs in a formula. The formula is not
calculating
and instead is showing up as the code itself.

This is the formula:
ActiveCell.FormulaR1C1 = _

"=IF(OR(RC[-2]=Cond1,RC[-2]=Cond2,RC[-2]=Cond3,RC[-2]=Cond4,RC[-2]=Cond5,RC[-2]=Cond6,RC[-2]=Cond7,RC[-2]=Cond8,RC[-2]=Cond9,RC[-2]=Cond10,RC[-2]=Cond11,RC[-2]=Cond12,RC[-2]=Cond13),""C&I"",RC[1])"

Once the code runs, the cells show this:
=IF(OR(RC[-2]=Cond1,RC[-2]=Cond2,RC[-2]=Cond3,RC[-2]=Cond4,RC[-2]=Cond5,RC[-2]=Cond6,RC[-2]=Cond7,RC[-2]=Cond8,RC[-2]=Cond9,RC[-2]=Cond10,RC[-2]=Cond11,RC[-2]=Cond12,RC[-2]=Cond13),"C&I",RC[1])


instead of the results. Note: COND1, cond2, cond3, cond4, etc. are a
named
range in another sheet. Can anyone please tell me why the code is not
calculating? As a side note....the cells are formatted as text after
code
run....and general before the code runs.



--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=120844

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Why does the Formula in VBA not calculate

yes...that is the formula I have. It is seperated by _
which is a line break.

"p45cal" wrote:


are you looking for:
Activecell.FormulaR1C1="=IF(OR(RC[-2]=Cond1,RC[-2]=Cond2,RC[-2]=Cond3,RC[-2]=Cond4,RC[-2]=Cond5,RC[-2]=Cond6,RC[-2]=Cond7,RC[-2]=Cond8,RC[-2]=Cond9,RC[-2]=Cond10,RC[-2]=Cond11,RC[-2]=Cond12,RC[-2]=Cond13),"&
"""C&I""" & ",RC[1])"

?

petedacook;435310 Wrote:
I have some code that plugs in a formula. The formula is not
calculating
and instead is showing up as the code itself.

This is the formula:
ActiveCell.FormulaR1C1 = _

"=IF(OR(RC[-2]=Cond1,RC[-2]=Cond2,RC[-2]=Cond3,RC[-2]=Cond4,RC[-2]=Cond5,RC[-2]=Cond6,RC[-2]=Cond7,RC[-2]=Cond8,RC[-2]=Cond9,RC[-2]=Cond10,RC[-2]=Cond11,RC[-2]=Cond12,RC[-2]=Cond13),""C&I"",RC[1])"

Once the code runs, the cells show this:
=IF(OR(RC[-2]=Cond1,RC[-2]=Cond2,RC[-2]=Cond3,RC[-2]=Cond4,RC[-2]=Cond5,RC[-2]=Cond6,RC[-2]=Cond7,RC[-2]=Cond8,RC[-2]=Cond9,RC[-2]=Cond10,RC[-2]=Cond11,RC[-2]=Cond12,RC[-2]=Cond13),"C&I",RC[1])


instead of the results. Note: COND1, cond2, cond3, cond4, etc. are a
named
range in another sheet. Can anyone please tell me why the code is not
calculating? As a side note....the cells are formatted as text after
code
run....and general before the code runs.



--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=120844


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Why does the Formula in VBA not calculate


Look _very__carefully, it is not the same.


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=120844



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Why does the Formula in VBA not calculate

I think Dave hit the nail on the head (or is it the head on the nail). Make
sure the cells are NOT formatted as Text. If the formatting is Text, Excel
will not perform any calculations for you. Format as Dave suggested, or
right-click the cell and choose your formatting preference (but not Text).
One quick way to tell if the cell is formatted as Text is to look at it and
if the characters are left justified, the cell is formatted as Text. If the
characters are right justified, the cell is not formatted as Text.

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"p45cal" wrote:


Look _very__carefully, it is not the same.


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=120844


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Why does the Formula in VBA not calculate


p45cal;438764 Wrote:
Look _very_ carefully, it is *not *the same.
I suggest copying and pasting - it worked here.


Yes, my apologies, although the formulae are different, they produce
the same result, so please ignore my posts on this one!


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=120844

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 a formula if yes calculate and if no 0 Saphire69 Excel Discussion (Misc queries) 2 March 27th 09 03:58 PM
Formula to calculate 401(k) carmelcorn45 Excel Worksheet Functions 1 November 2nd 06 04:26 PM
Formula does not calculate - Have tried F9 Anisette Excel Worksheet Functions 9 July 27th 06 04:37 AM
formula does not calculate TaiwanSwede Excel Discussion (Misc queries) 5 July 19th 06 12:22 PM
Calculate formula only once. smunn Excel Discussion (Misc queries) 2 December 22nd 05 09:32 PM


All times are GMT +1. The time now is 08:37 AM.

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"