Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Conditional formatting

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 =(C110) then
=mnb(C1) should display =(C110), instead it is displaying =(Z10010) 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

--
Gary''s Student gsnu
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Conditional formatting

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

--
Regards,
Tom Ogilvy


"Gary''s Student" wrote in message
...
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 =(C110) then
=mnb(C1) should display =(C110), instead it is displaying =(Z10010) 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

--
Gary''s Student gsnu



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Conditional formatting

Your solution works just fine.

Thanks

If I could trouble you a little more, what was wrong with what I was trying??
--
Gary's Student


"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy


"Gary''s Student" wrote in message
...
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 =(C110) then
=mnb(C1) should display =(C110), instead it is displaying =(Z10010) 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

--
Gary''s Student gsnu




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Conditional formatting

It doesn't work.

--
Regards,
Tom Ogilvy

"Gary''s Student" wrote in message
...
Your solution works just fine.

Thanks

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

trying??
--
Gary's Student


"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy


"Gary''s Student" wrote in

message
...
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 =(C110) then
=mnb(C1) should display =(C110), instead it is displaying =(Z10010)

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

--
Gary''s Student gsnu






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 can I convert conditional formatting into explicit formatting? Patrick Harris Excel Discussion (Misc queries) 0 April 9th 09 12:00 AM
Formatting Conditional Formatting Icon Sets The Rook[_2_] Excel Discussion (Misc queries) 3 March 7th 09 08:48 PM
Protect Cell Formatting including Conditional Formatting Mick Jennings Excel Discussion (Misc queries) 5 November 13th 07 05:32 PM
conditional Formatting based on cell formatting Totom Excel Worksheet Functions 3 January 20th 07 02:02 PM
Conditional Formatting that will display conditional data BrainFart Excel Worksheet Functions 1 September 13th 05 05:45 PM


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