Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default Macro syntax problem - Dean

I have the following formula in EXCEL (it works)

=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,"=y",C55:C77)

which I want to have visual basic type into the current cell.

Here is my attempt at writing it in VBA but I am getting a compile error
(expected end of statement). Can someone help me, please with my syntax
(perhaps sumif doesn't work in VBA, or perhaps I have left out a comma or
something)?

ActiveCell.FormulaR1C1 =
"=H78*PerfPercent*ScalingFactor*C78/SUMIF(R[-23]C[-3]:R[-1]C[-3]," = Y
",R[-23]C[-6]:R[-1]C[-6])"

Thanks!
Dean


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Macro syntax problem - Dean

On Fri, 24 Aug 2007 18:16:38 -0700, "Dean" wrote:

I have the following formula in EXCEL (it works)

=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,"=y",C55:C77)

which I want to have visual basic type into the current cell.

Here is my attempt at writing it in VBA but I am getting a compile error
(expected end of statement). Can someone help me, please with my syntax
(perhaps sumif doesn't work in VBA, or perhaps I have left out a comma or
something)?

ActiveCell.FormulaR1C1 =
"=H78*PerfPercent*ScalingFactor*C78/SUMIF(R[-23]C[-3]:R[-1]C[-3]," = Y
",R[-23]C[-6]:R[-1]C[-6])"

Thanks!
Dean


When you have quote marks within your formula, which is a string, you've got to
double them so VBA doesn't think it's the end of the string:

.... C[-3],""=Y"",R[-23] ...


--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default Macro syntax problem - Dean

Thanks, it compiles now but it is producing the wrong equation.
Specifically,

The H78 has apostrophes on either side of it. And the C78 has been replaced
with $bz:$bz

Any idea why?

Thanks again
Dean


"Ron Rosenfeld" wrote in message
...
On Fri, 24 Aug 2007 18:16:38 -0700, "Dean"
wrote:

I have the following formula in EXCEL (it works)

=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,"=y",C55:C77)

which I want to have visual basic type into the current cell.

Here is my attempt at writing it in VBA but I am getting a compile error
(expected end of statement). Can someone help me, please with my syntax
(perhaps sumif doesn't work in VBA, or perhaps I have left out a comma or
something)?

ActiveCell.FormulaR1C1 =
"=H78*PerfPercent*ScalingFactor*C78/SUMIF(R[-23]C[-3]:R[-1]C[-3]," = Y
",R[-23]C[-6]:R[-1]C[-6])"

Thanks!
Dean


When you have quote marks within your formula, which is a string, you've
got to
double them so VBA doesn't think it's the end of the string:

... C[-3],""=Y"",R[-23] ...


--ron



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Macro syntax problem - Dean

On Fri, 24 Aug 2007 18:55:22 -0700, "Dean" wrote:

Thanks, it compiles now but it is producing the wrong equation.
Specifically,

The H78 has apostrophes on either side of it. And the C78 has been replaced
with $bz:$bz

Any idea why?

Thanks again
Dean


In R1C1 format, H78 is just a string, not a cell address, and C78 is the 78th
column which is column BZ in A1 format. If those values are meant to be cell
addresses, you need to put them in R1C1 format and not in A1 format (like the
rest of your formula).
--ron
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default Macro syntax problem - Dean

Ahh, I see. Thanks much.

"Ron Rosenfeld" wrote in message
...
On Fri, 24 Aug 2007 18:55:22 -0700, "Dean"
wrote:

Thanks, it compiles now but it is producing the wrong equation.
Specifically,

The H78 has apostrophes on either side of it. And the C78 has been
replaced
with $bz:$bz

Any idea why?

Thanks again
Dean


In R1C1 format, H78 is just a string, not a cell address, and C78 is the
78th
column which is column BZ in A1 format. If those values are meant to be
cell
addresses, you need to put them in R1C1 format and not in A1 format (like
the
rest of your formula).
--ron





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default Macro syntax problem - Dean

try
ActiveCell.Formula =
"=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,""=y"", C55:C77)"
or
range("A1").formula
="=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,""=y"", C55:C77)"
--


Gary

"Dean" wrote in message
...
Thanks, it compiles now but it is producing the wrong equation.
Specifically,

The H78 has apostrophes on either side of it. And the C78 has been
replaced with $bz:$bz

Any idea why?

Thanks again
Dean


"Ron Rosenfeld" wrote in message
...
On Fri, 24 Aug 2007 18:16:38 -0700, "Dean"
wrote:

I have the following formula in EXCEL (it works)

=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,"=y",C55:C77)

which I want to have visual basic type into the current cell.

Here is my attempt at writing it in VBA but I am getting a compile error
(expected end of statement). Can someone help me, please with my syntax
(perhaps sumif doesn't work in VBA, or perhaps I have left out a comma or
something)?

ActiveCell.FormulaR1C1 =
"=H78*PerfPercent*ScalingFactor*C78/SUMIF(R[-23]C[-3]:R[-1]C[-3]," = Y
",R[-23]C[-6]:R[-1]C[-6])"

Thanks!
Dean


When you have quote marks within your formula, which is a string, you've
got to
double them so VBA doesn't think it's the end of the string:

... C[-3],""=Y"",R[-23] ...


--ron




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default Macro syntax problem - Dean

Oh, I like this much better than the other format I started with. I guess I
grabbed whatever code that I had and tried to modify it, without thinking to
ask, if I could do it this way. Silly, silly me!

Now I know two ways, with Ron's help, which is good.

Thanks!
Dean

"Gary Keramidas" wrote in message
...
try
ActiveCell.Formula =
"=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,""=y"", C55:C77)"
or
range("A1").formula
="=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,""=y"", C55:C77)"
--


Gary

"Dean" wrote in message
...
Thanks, it compiles now but it is producing the wrong equation.
Specifically,

The H78 has apostrophes on either side of it. And the C78 has been
replaced with $bz:$bz

Any idea why?

Thanks again
Dean


"Ron Rosenfeld" wrote in message
...
On Fri, 24 Aug 2007 18:16:38 -0700, "Dean"
wrote:

I have the following formula in EXCEL (it works)

=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,"=y",C55:C77)

which I want to have visual basic type into the current cell.

Here is my attempt at writing it in VBA but I am getting a compile error
(expected end of statement). Can someone help me, please with my syntax
(perhaps sumif doesn't work in VBA, or perhaps I have left out a comma
or
something)?

ActiveCell.FormulaR1C1 =
"=H78*PerfPercent*ScalingFactor*C78/SUMIF(R[-23]C[-3]:R[-1]C[-3]," = Y
",R[-23]C[-6]:R[-1]C[-6])"

Thanks!
Dean


When you have quote marks within your formula, which is a string, you've
got to
double them so VBA doesn't think it's the end of the string:

... C[-3],""=Y"",R[-23] ...


--ron






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default Macro syntax problem - Dean

Actually, I have one new problem. I put the following line of code into a
macro that had been working perfectly and now it crashes at this line with
an application defined or object defined error message. Am I screwing up
the syntax again? From what I can tell, both cells C55 and H55 have numbers
in them.

Range("C200").Select
ActiveCell.Formula = "=IF(H55="",0,H55-C55)" ' need to do this because
the cells have moved

Thanks!
Dean


"Dean" wrote in message
...
Oh, I like this much better than the other format I started with. I guess
I grabbed whatever code that I had and tried to modify it, without
thinking to ask, if I could do it this way. Silly, silly me!

Now I know two ways, with Ron's help, which is good.

Thanks!
Dean

"Gary Keramidas" wrote in message
...
try
ActiveCell.Formula =
"=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,""=y"", C55:C77)"
or
range("A1").formula
="=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,""=y"", C55:C77)"
--


Gary

"Dean" wrote in message
...
Thanks, it compiles now but it is producing the wrong equation.
Specifically,

The H78 has apostrophes on either side of it. And the C78 has been
replaced with $bz:$bz

Any idea why?

Thanks again
Dean


"Ron Rosenfeld" wrote in message
...
On Fri, 24 Aug 2007 18:16:38 -0700, "Dean"
wrote:

I have the following formula in EXCEL (it works)

=H78*PerfPercent*ScalingFactor*C78/SUMIF(F55:F77,"=y",C55:C77)

which I want to have visual basic type into the current cell.

Here is my attempt at writing it in VBA but I am getting a compile
error
(expected end of statement). Can someone help me, please with my
syntax
(perhaps sumif doesn't work in VBA, or perhaps I have left out a comma
or
something)?

ActiveCell.FormulaR1C1 =
"=H78*PerfPercent*ScalingFactor*C78/SUMIF(R[-23]C[-3]:R[-1]C[-3]," = Y
",R[-23]C[-6]:R[-1]C[-6])"

Thanks!
Dean


When you have quote marks within your formula, which is a string,
you've got to
double them so VBA doesn't think it's the end of the string:

... C[-3],""=Y"",R[-23] ...


--ron







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
Copy And Paste Macro Syntax Problem Minitman Excel Worksheet Functions 2 March 27th 08 01:59 AM
Do Until syntax problem excelnut1954 Excel Programming 5 October 21st 06 12:50 AM
Req: Help requested with Macro problem and syntax errors (any fisherman out there!!) bob M Excel Programming 1 December 13th 05 06:09 PM
How do you insert an & sign in a footer? i.e. Dean & Deluca Sarah Excel Discussion (Misc queries) 1 April 6th 05 06:07 PM
Syntax problem in defining OnAction macro definition held in Add-in! Charles Jordan Excel Programming 4 March 5th 05 06:35 AM


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