Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Conditional format question

Using conditional formatting, is there any way to turn Cell A1 red if a
conditional format has been applied to any cells in the range D1:H1?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Conditional format question

You could create a user defined function that checks the range for the
same conditions as the conditional formatting in range D1:H1 checks
for. As a simple example, if the conditional formatting for D1:H1 is
applied for values 5, the user defined function might look like:

Public Function myUDF(ByRef TargetRange As Range) As Boolean

Dim r As Range
For Each r In TargetRange.Cells
If r.Value 5 Then
myUDF = True
Exit Function
End If
Next
myUDF = False

End Function


Then in A1's conditional formatting, select "Formula is" from the
dropdown and enter =myUDF(D1:H1) and select the formatting for a TRUE
condition.

Would this work for you?

Nick Hebb
BreezeTree Software
http://www.breezetree.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Conditional format question

Hi Patrick,

Try using the following UDF as the CF condition for cell A1:

'================
Public Function CFApplied(rng As Range) As Boolean
Dim rCell As Range

For Each rCell In rng.Cells
If rCell.FormatConditions.Count Then
CFApplied = True
Exit For
End If
Next rCell
End Function
'<<================

The CF condition for A1 would then be:

Formula Is: =CFApplied($D$1:$H1)

---
Regards,
Norman


"Patrick Simonds" wrote in message
...
Using conditional formatting, is there any way to turn Cell A1 red if a
conditional format has been applied to any cells in the range D1:H1?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Conditional format question

Norman, I believe that function will return TRUE even if the
conditional formating in D1:H1 is not applied.

Nick Hebb
BreezeTree Software
http://www.breezetree.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Conditional format question

Hi Nick,

Norman, I believe that function will return TRUE even if the
conditional formating in D1:H1 is not applied.


Running:
'===========
Sub Testit()
Dim RngTest As Range

Set RngTest = Range("D1, F1, H1")

With RngTest

.FormatConditions.Delete

.FormatConditions.Add _
Type:=xlCellValue, _
Operator:=xlGreater, _
Formula1:="100"
Debug.Print CFApplied(RngTest), "Some CF"

.FormatConditions.Delete

Debug.Print CFApplied(RngTest), "No CF"
End With

End Sub
'===========

Returned:

True Some CF
False No CF

for me.

---
Regards,
Norman


"Nick Hebb" wrote in message
oups.com...
Norman, I believe that function will return TRUE even if the
conditional formating in D1:H1 is not applied.

Nick Hebb
BreezeTree Software
http://www.breezetree.com





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Conditional format question

If you mean -

a) The range has been applied with CF's and you want to know if any of the
cells show the CF format because of a true condition, see Nick's suggestion.

or

b) You want to know if CF's have been applied to any cells in the range,
regardless as to whether any conditions are true and one or more CF formats
display, see Norman's suggestion.

The latter is the correct literal interpretation of your question. But
somehow I suspect you mean the former. (?)

Regards,
Peter T


"Patrick Simonds" wrote in message
...
Using conditional formatting, is there any way to turn Cell A1 red if a
conditional format has been applied to any cells in the range D1:H1?




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
conditional format question - I think... simon Excel Worksheet Functions 3 November 5th 07 07:19 PM
Another Conditional Format Question PT New Users to Excel 3 April 29th 07 02:42 AM
Conditional Format Question PT New Users to Excel 1 April 28th 07 03:55 AM
conditional format question Anthony Excel Worksheet Functions 4 March 8th 07 08:17 PM
Another Conditional format question Corben Excel Worksheet Functions 8 April 28th 06 05:46 PM


All times are GMT +1. The time now is 08:34 AM.

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"