Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default using a variable for MOD Statement

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 cod
=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??
  #2   Report Post  
Posted to microsoft.public.excel.programming
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??


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default using a variable for MOD Statement

YES!!! Thank you so much! You just saved me HOURS of work! BTW, it worked
like a charm! Thanks again.

"Scott" wrote:

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??



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
Variable statement doobie Excel Discussion (Misc queries) 3 November 11th 09 07:42 AM
Variable in if statement Francis Hookham Excel Worksheet Functions 9 December 12th 07 02:35 PM
IF Statement Variable Jase4now Excel Discussion (Misc queries) 3 September 25th 07 10:48 PM
if than statement has too many variable repke New Users to Excel 1 May 2nd 06 02:00 PM
Macro Creating Variable and using variable in a SQL statement Jimmy Excel Programming 4 October 25th 04 02:36 AM


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