View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Scott Scott is offline
external usenet poster
 
Posts: 87
Default using a variable for MOD Statement

Are you trying to perform this calculation in VBA, or are you trying to
assign this formula to a cell?

If you're trying to assign this formula to a cell, you probably want to
do something like:

Range("A1").FormulaR1C1 = "=SUM(IF(MOD(ROW(R3C12:R" & MaxNumRows &
"C12)-ROW(R3C12)+1,3)=0,R3C12:R" & MaxNumRows & "C12,0))"

Scott

bethg7 wrote:
I make a report that has a varying number of rows and I use the variable
"MaxNumRows". The totals line for the report = MaxNumRows +3. Works great
so far!

I am using the code
=SUM(IF(MOD(ROW(R3C12:R(MaxNumRows)C12)-ROW(R3C12)+1,3)=0,R3C12:R(MaxNumRows)C12,0))

Doesn't work! I use MaxNumRows in other formulas; but it isn't working in
THIS one. How can I make this formula become ...ROW(R3C12:R20C12) if the
MaxNumRows = 20??