Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Regression Leverage Formula (Jerry W. Lewis or Mike Middleton)already have DFITS formula | Excel Worksheet Functions | |||
copy formula down a column and have cell references change within formula | New Users to Excel | |||
Formula expected end of statement error, typing formula into cell as part of VBA macro | Excel Programming | |||
Cell doesn't show formula result - it shows formula (CTRL + ' doe. | Excel Worksheet Functions | |||
Commenting custom formula fields/formula on formula editor | Excel Programming |