how can i write a FormulaR1C1 in vba?
i want to set the formula in cell V2 to "=IF(SUM(B2:U2)>0,SUM(B2:U2),"")"
how can i do that in my macro?
question2: how do i filldown column V?
how can i write a FormulaR1C1 in vba?
i want to set the formula in cell V2 to "=IF(SUM(B2:U2)>0,SUM(B2:U2),"")"
how can i do that in my macro?
question2: how do i filldown column V?
Last edited by .paul.; 01-26-2009 at 12:27 PM.
That's not an R1C1 formula. If you want to enter the formula you have,
![]()
range("v2").formula = "=IF(SUM(B2:U2)>0, SUM(B2:U2), """")"
Entia non sunt multiplicanda sine necessitate
Hi
1)2) If you can find the last relevant row, then put it into a variable. Assuming that column A will give you the last row then![]()
range("V2").formula = "=IF(SUM(B2:U2)>0,SUM(B2:U2),"""")"
rylo![]()
lastrow = cells(rows.count,"A").end(xlup).row range("V2").autofill destination:=range("V2:V" & lastrow)
How do you determine where to fill down to? This could be one way
![]()
Option Explicit Sub addFormula() Dim LastRow As Long With Sheet1 '<-change the sheet reference LastRow = .UsedRange.Rows.Count .Range(.Cells(2, 22), .Cells(LastRow, 22)).FormulaR1C1 = _ "=IF(SUM(RC[-20]:RC[-1])>0,SUM(RC[-20]:RC[-1]),"""")" End With End Sub
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
how do i mark this thread SOLVED?
See VBA Help for the ConvertFormula method.yeah i know. i wanted to convert it to a R1C1 formula...
Click the Edit button on your first post in the threadhow do i mark this thread SOLVED?
Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes
Last edited by shg; 01-26-2009 at 12:15 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks