Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 48
Default If function using cell format as the condition

I would like to create an "If" logical function formula, where the "true"
condition is based on the format of the cell.

For instance, if cell b3 is formatting with a fill color, then add that
number; if not, then add zero.

Can anyone help?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,651
Default If function using cell format as the condition

That will need VBA, unless the fill colour is derived from conditional
formatting (in which case you could impose an equivalent condition).
--
David Biddulph

"Janie" wrote in message
...
I would like to create an "If" logical function formula, where the "true"
condition is based on the format of the cell.

For instance, if cell b3 is formatting with a fill color, then add that
number; if not, then add zero.

Can anyone help?



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default If function using cell format as the condition

There is no built-in excel function to do this. But you can use a UDF that
looks at the range and returns the sum of color. But that function will not
recalculate if you change color. Every time you change the color you will
need to recalculate or wait excel to recalculate...

To install the UDF (User Defined function). From workbook launch VBE using
Alt+F11. From menu Insert a Module and paste the below function.Close and get
back to workbook and try the below formula.

=colorsum(A5:A9,D5)
cell D5 will have the fill color which is the query color...to be searched
in the range A5:A9

'If you mean to sum the cell values with matching color then
Function ColorSum(varRange As Range, varColor As Range)
Dim arrTemp As Variant, varTemp As Variant
For Each cell In varRange
varTemp = cell.Interior.ColorIndex
If varTemp = varColor.Interior.ColorIndex Then ColorSum = ColorSum +
cell.Value
Next
End Function

--
Jacob


"Janie" wrote:

I would like to create an "If" logical function formula, where the "true"
condition is based on the format of the cell.

For instance, if cell b3 is formatting with a fill color, then add that
number; if not, then add zero.

Can anyone help?

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default If function using cell format as the condition

Use the below code instead....(the previous one might give you syntax issues
due to text alignment)

'If you mean to sum the cell values with matching color then
Function ColorSum(varRange As Range, varColor As Range)
Dim arrTemp As Variant, varTemp As Variant
For Each cell In varRange
varTemp = cell.Interior.ColorIndex
If varTemp = varColor.Interior.ColorIndex Then
ColorSum = ColorSum + cell.Value
End If
Next
End Function

--
Jacob


"Jacob Skaria" wrote:

There is no built-in excel function to do this. But you can use a UDF that
looks at the range and returns the sum of color. But that function will not
recalculate if you change color. Every time you change the color you will
need to recalculate or wait excel to recalculate...

To install the UDF (User Defined function). From workbook launch VBE using
Alt+F11. From menu Insert a Module and paste the below function.Close and get
back to workbook and try the below formula.

=colorsum(A5:A9,D5)
cell D5 will have the fill color which is the query color...to be searched
in the range A5:A9

'If you mean to sum the cell values with matching color then
Function ColorSum(varRange As Range, varColor As Range)
Dim arrTemp As Variant, varTemp As Variant
For Each cell In varRange
varTemp = cell.Interior.ColorIndex
If varTemp = varColor.Interior.ColorIndex Then ColorSum = ColorSum +
cell.Value
Next
End Function

--
Jacob


"Janie" wrote:

I would like to create an "If" logical function formula, where the "true"
condition is based on the format of the cell.

For instance, if cell b3 is formatting with a fill color, then add that
number; if not, then add zero.

Can anyone help?

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
Condition Format with 2 cell Kim Excel Worksheet Functions 5 February 27th 09 11:07 AM
Cell format as condition mars Excel Worksheet Functions 1 November 24th 08 02:17 AM
multiple condition lookup and match cell format CJ at home Excel Worksheet Functions 3 August 27th 06 03:56 PM
Can I condition format, "if the cell contains a formula" kvail Excel Worksheet Functions 3 June 28th 06 09:01 PM
Keep cell blank if condition is false in IF function ruthslaughter Excel Discussion (Misc queries) 2 November 23rd 05 01:15 PM


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