#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 661
Default Formats in formulas

Hey there,
is there any way in which logical test used in a formula could be, for
example,
"if(valueA=red text, value if true, value if false)"
or is there some other way in which the formatting of a value can influence
output
Sort of like the opposite of conditional formatting?

Any help would be appreciated,
Paul :)
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 510
Default Formats in formulas

Hi

Use an UDF to return format value.


Arvi Laanemets


"Paul" wrote in message
...
Hey there,
is there any way in which logical test used in a formula could be, for
example,
"if(valueA=red text, value if true, value if false)"
or is there some other way in which the formatting of a value can
influence
output
Sort of like the opposite of conditional formatting?

Any help would be appreciated,
Paul :)



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default Formats in formulas

Hi,

You would need to use VBA. Here is a simple example

Here is a custom function to count cells base on font color and fill color:

Function CountFormats(R As Range, E As Range) As Integer
Dim cell As Range
Dim Total As Integer
Application.Volatile
Set S = E.Cells(1, 1)
Total = 0
For Each cell In R
With cell
If .Interior.ColorIndex = S.Interior.ColorIndex _
And .Font.ColorIndex = S.Font.ColorIndex Then
Total = Total + 1
End If
End With
Next cell
CountFormats = Total
End Function

In the spreadsheet you enter =countformats(A2:B7,D2) Where A2:B7 is the
range you want to check and D2 is a cell formatted to the desired format.

To add this code to a workbook press Alt+F11 and select your file in the
Project explorer in the top left side of the screen. Choose Insert, Module.
Put the code in the resulting module.

If this helps, please click the Yes button

Cheers,
Shane Devenshire

"Paul" wrote:

Hey there,
is there any way in which logical test used in a formula could be, for
example,
"if(valueA=red text, value if true, value if false)"
or is there some other way in which the formatting of a value can influence
output
Sort of like the opposite of conditional formatting?

Any help would be appreciated,
Paul :)

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 53
Default Formats in formulas

Hi,
you can use the formula:
=CELL("color",A1)

this would return a value 1, if cell font (only) is done with a color

like
#,##0_);[Red](#,##0) --- (negative numbers in red color and parenthesis)
;[Red]($#,##0.00); ---(negative numbers in red color and parenthesis)
[Green]#,##0_); ---(positive numbers in green color)

one point to note is that there should be one ;(semicolon) in the format

--
Please Click yes if this post was useful.

Kind Regards,
Satti Charvak
Only an Excel Enthusiast


"Paul" wrote:

Hey there,
is there any way in which logical test used in a formula could be, for
example,
"if(valueA=red text, value if true, value if false)"
or is there some other way in which the formatting of a value can influence
output
Sort of like the opposite of conditional formatting?

Any help would be appreciated,
Paul :)

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
Can formats follow formulas? Phrank Excel Worksheet Functions 2 June 10th 06 03:09 AM
What's the best way to add a row and copy formulas and formats? Michael at Sigcon Excel Discussion (Misc queries) 1 March 17th 06 02:43 PM
Extend formats and formulas JRB Excel Discussion (Misc queries) 11 August 28th 05 08:21 PM
Cell Formats in formulas C. Lewis Excel Discussion (Misc queries) 1 January 5th 05 06:37 PM
extend data range formats and formulas Lonnie Setting up and Configuration of Excel 1 December 10th 04 11:33 PM


All times are GMT +1. The time now is 03:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"