Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default inserting formulae

I am a novice in programming excel. I am trying to insert formula
through macro in a cell by using Formulaarray. I am encountering a
peculiar problem.

Formula i want to insert is

=-IF(UPPER($EC$14)="Y",AH22*AI22,AN22)*R22*SUMIF(PAY MENT_INDEX,"="
&F22,RNG_OPT_PREM)/COUNTIF(PAYMENT_INDEX,&F22)

Now if i want to insert it in A1 say,

i would write

A1.formulaArray =
"=-IF(UPPER($EC$14)="Y",AH22*AI22,AN22)*R22*SUMIF(PAY MENT_INDEX,"="
&F22,RNG_OPT_PREM)/COUNTIF(PAYMENT_INDEX,&F22)"

But VBA recognizes the starting inverted commas of the "Y" as the end
of formula and gives me syntax error.
How do i overcome this?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default inserting formulae

I think you can do this by using double double quotes inside the formula array

eg.
A1.formulaArray =
"=-IF(UPPER($EC$14)=""Y"",AH22*AI22,AN22)*R22*SUMIF(P AYMENT_INDEX,""=""&F22,RNG_OPT_PREM)/COUNTIF(PAYMENT_INDEX,&F22)"

" wrote:

I am a novice in programming excel. I am trying to insert formula
through macro in a cell by using Formulaarray. I am encountering a
peculiar problem.

Formula i want to insert is


=-IF(UPPER($EC$14)="Y",AH22*AI22,AN22)*R22*SUMIF(PAY MENT_INDEX,"="
&F22,RNG_OPT_PREM)/COUNTIF(PAYMENT_INDEX,&F22)

Now if i want to insert it in A1 say,

i would write

A1.formulaArray =
"=-IF(UPPER($EC$14)="Y",AH22*AI22,AN22)*R22*SUMIF(PAY MENT_INDEX,"="
&F22,RNG_OPT_PREM)/COUNTIF(PAYMENT_INDEX,&F22)"

But VBA recognizes the starting inverted commas of the "Y" as the end
of formula and gives me syntax error.
How do i overcome this?

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default inserting formulae



" wrote:

I am a novice in programming excel. I am trying to insert formula
through macro in a cell by using Formulaarray. I am encountering a
peculiar problem.

Formula i want to insert is

=-IF(UPPER($EC$14)="Y",AH22*AI22,AN22)*R22*SUMIF(PAY MENT_INDEX,"="
&F22,RNG_OPT_PREM)/COUNTIF(PAYMENT_INDEX,&F22)

Now if i want to insert it in A1 say,

i would write

A1.formulaArray =
"=-IF(UPPER($EC$14)="Y",AH22*AI22,AN22)*R22*SUMIF(PAY MENT_INDEX,"="
&F22,RNG_OPT_PREM)/COUNTIF(PAYMENT_INDEX,&F22)"

But VBA recognizes the starting inverted commas of the "Y" as the end
of formula and gives me syntax error.
How do i overcome this?

Thanks

Your code looks fine to me, but I believe the problem you are running into happens constantly in scripting. It's the tics. You should alternate the ' and the " signs. That is how the code code is compiled. The " sign signals the end of a line of code so to avoid this alternate with a set of tics which look like this ' . I apologize for having a problem expressing this but I am reasonably sure this is the situation.


Robert Carmon
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
Auto fill formulae when inserting rows Riker1074 Excel Discussion (Misc queries) 9 December 30th 08 03:56 PM
Inserting worksheet makes formulae stop working Mark Excel Discussion (Misc queries) 5 April 24th 08 07:10 PM
Inserting new row but keeping formulae Alex Simpson Excel Worksheet Functions 0 August 8th 06 01:16 PM
inserting formulae [email protected] Excel Worksheet Functions 2 May 9th 06 02:08 PM
Subtotals and inserting formulae jandro Excel Programming 4 July 26th 05 02:50 PM


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