Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Conditional formatting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary''s Student - 28 Feb 2006 14:26 GMT
I need a function that, given a range (single cell) as an argument, will
determine if the cell has been conditionally formatted with EquationIs and,
if yes, return the first formula as a text string.  I tried:

Function mnb(r As Range) As String
mnb = r.FormatConditions(1).Formula1
End Function

This almost works, but it returns equations with cell references translated
to the location of the function call rather than the range in the call.  For
example, if the conditional formatting in C1 is formula =(C1>10) then
=mnb(C1) should display =(C1>10), instead it is displaying =(Z100>10) if
=mnb(C1) happens to be in Z100.

As a sub there is no problem:

Sub macro3()
Dim r As Range
Dim s As String
Set r = Selection
s = r.FormatConditions(1).Formula1
MsgBox (s)
End Sub

Thanks in Advance

Signature

Gary''s Student gsnu

Tom Ogilvy - 28 Feb 2006 15:08 GMT
I don't know if this is a general solution, but try this:

Function mnb(r As Range) As String
Dim s As String, s1 As String, s2 As String
s = r.FormatConditions(1).Formula1
s1 = Application.ConvertFormula(s, xlA1, xlR1C1, , ActiveCell)
s2 = Application.ConvertFormula(s1, xlR1C1, xlA1, , r)
mnb = s2
End Function

Signature

Regards,
Tom Ogilvy

> I need a function that, given a range (single cell) as an argument, will
> determine if the cell has been conditionally formatted with EquationIs and,
[quoted text clipped - 21 lines]
>
> Thanks in Advance
Gary''s Student - 28 Feb 2006 15:45 GMT
Your solution works just fine.

Thanks

If I could trouble you a little more, what was wrong with what I was trying??
Signature

Gary's Student

> I don't know if this is a general solution, but try this:
>
[quoted text clipped - 34 lines]
> >
> > Thanks in Advance
Tom Ogilvy - 28 Feb 2006 16:05 GMT
It doesn't work.

Signature

Regards,
Tom Ogilvy

> Your solution works just fine.
>
[quoted text clipped - 40 lines]
> > >
> > > Thanks in Advance
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.