Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Sum If - Using the value of a parameter or constant in a formula tochange a condition

I have created a macro to sum a range of cells based on a condition in
a particular cell which works fine.
The overall procedure is quite long and the condition is used many
times to carry out different actions.
I would like to be able to change the condition in the formula using a
variable or constant rather than having to edit each instance of the
condition. The the condition, in this case 20, is the number of
characters in the first cell in a row. But depending on which data
the procedure is being applied to it could be 4, 8, 12, etc. I would
like to do something such as declare a constant "Const Level01 As
Integer = 20" and then replace 20 in the formula with the value of
the constant or perhaps a variable. It doesn't change value in the
running of the procedure so I thought a constant would best. It might
be something that I would want to derive the value from using an input
box with changeable default values at some stage, but one step at a
time.


Case Is = "Total"
Cell.Offset(0, 11).FormulaArray = "=(SUM(IF(LEN
(R6C1:R5000C1)20,R6C11:R5000C11,0)))"
With Cell.EntireRow
.RowHeight = 36

I've struggled to make it work and would be grateful for any help
given.
Ritchi
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Sum If - Using the value of a parameter or constant in a formula to change a condition

Hi Ritchi

Try this:

Static Level01 As Long
Level01 = 20
Case Is = "Total"
myformula = _
"=(SUM(IF(LEN(R6C1:R5000C1)" & Level01 & ",R6C11:R5000C11,0)))"
ActiveCell.Offset(0, 11).FormulaArray = myformula

Regards,
Per
"RITCHI" skrev i meddelelsen
...
I have created a macro to sum a range of cells based on a condition in
a particular cell which works fine.
The overall procedure is quite long and the condition is used many
times to carry out different actions.
I would like to be able to change the condition in the formula using a
variable or constant rather than having to edit each instance of the
condition. The the condition, in this case 20, is the number of
characters in the first cell in a row. But depending on which data
the procedure is being applied to it could be 4, 8, 12, etc. I would
like to do something such as declare a constant "Const Level01 As
Integer = 20" and then replace 20 in the formula with the value of
the constant or perhaps a variable. It doesn't change value in the
running of the procedure so I thought a constant would best. It might
be something that I would want to derive the value from using an input
box with changeable default values at some stage, but one step at a
time.


Case Is = "Total"
Cell.Offset(0, 11).FormulaArray = "=(SUM(IF(LEN
(R6C1:R5000C1)20,R6C11:R5000C11,0)))"
With Cell.EntireRow
.RowHeight = 36

I've struggled to make it work and would be grateful for any help
given.
Ritchi


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
How toChange color of first letter inEach word ofA column at once LSSK Excel Discussion (Misc queries) 1 February 7th 10 03:14 PM
formula vs constant rk0909 Excel Discussion (Misc queries) 1 January 14th 10 03:03 AM
Set a constant from a formula in VBA Ed Excel Discussion (Misc queries) 1 December 1st 06 01:31 AM
How tochange color of MINIF cell ? Mima Excel Programming 5 November 14th 05 02:16 PM
Constant in Formula Sige Excel Programming 27 September 28th 05 08:21 AM


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