Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default formula in VBA

Is the Friday afternoon?
I'm trying to create a formula in VBA. The formula is:
=IF(I3<"",IF(J3<"",SUM(J3:L3)*I3+M3,""),"")
I've written the code, but VBA is not accepting it. So far I have:
..Cells(lNextRow, "N").Formula = "=IF(I" & lNextRow & "<"""","IF(J" &
lNextRow & "<"""","SUM(J" & lNextRow & ":L" & lNextRow & ")*I" & lnextrow
&"+M" & lnextrow & ",""""),"""")"

But it's in red. I can't see what's wrong. Does anyone see it?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default formula in VBA

..Cells(lNextRow, "N").Formula = _
"=IF(I" & lnextrow & "<"""",IF(J" & lnextrow & _
"<"""",SUM(J" & lnextrow & ":L" & lnextrow & _
")*I" & lnextrow & "+M" & lnextrow & ",""""),"""")"

Another way to embed double-quotes is to use a variable or constant. Can be
easier to write and debug, IMO.

Const DQ As String = """"

..Cells(lNextRow, "N").Formula = _
"=IF(I" & lnextrow & "<" & DQ & DQ & _
",IF(J" & lnextrow & "<" & DQ & DQ & _
",SUM(J" & lnextrow & ":L" & lnextrow & ")*I" & _
lnextrow & "+M" & lnextrow & "," & DQ & DQ & ")," & DQ & DQ & ")"


--
Tim Zych
www.higherdata.com
Compare data in Excel and find differences with Workbook Compare
A free, powerful, flexible Excel utility



"Dave" wrote in message
. ..
Is the Friday afternoon?
I'm trying to create a formula in VBA. The formula is:
=IF(I3<"",IF(J3<"",SUM(J3:L3)*I3+M3,""),"")
I've written the code, but VBA is not accepting it. So far I have:
.Cells(lNextRow, "N").Formula = "=IF(I" & lNextRow & "<"""","IF(J" &
lNextRow & "<"""","SUM(J" & lNextRow & ":L" & lNextRow & ")*I" & lnextrow
&"+M" & lnextrow & ",""""),"""")"

But it's in red. I can't see what's wrong. Does anyone see it?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default formula in VBA

On Fri, 11 Jul 2008 14:31:56 -0700, Tim Zych wrote:

.Cells(lNextRow, "N").Formula = _
"=IF(I" & lnextrow & "<"""",IF(J" & lnextrow & _
"<"""",SUM(J" & lnextrow & ":L" & lnextrow & _
")*I" & lnextrow & "+M" & lnextrow & ",""""),"""")"


Thanks!
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
Regression Leverage Formula (Jerry W. Lewis or Mike Middleton)already have DFITS formula PJ[_3_] Excel Worksheet Functions 2 June 2nd 10 03:45 PM
copy formula down a column and have cell references change within formula brad New Users to Excel 5 May 13th 07 04:38 PM
Formula expected end of statement error, typing formula into cell as part of VBA macro [email protected] Excel Programming 1 July 20th 06 07:58 PM
Cell doesn't show formula result - it shows formula (CTRL + ' doe. o0o0o0o Excel Worksheet Functions 6 November 19th 04 03:13 PM
Commenting custom formula fields/formula on formula editor Muxer Excel Programming 2 July 24th 03 01:02 AM


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