OK I see your point. In haste to concede "I misread" and beat you to it, I
didn't take a close look at all the implications. I have since though looked
at my own function (I mentioned earlier) that does cater for the scenario
you refer to. FWIW, a tiny snippet:
For each cell in rng
For each fc in cell.formatconditions
' some other stuff
vF1 = Evaluate(fc.Formula1)
If fc.Type = xlExpression Then
bln = vF1
Else
If fc.Operator < 3 Then vF2 = Evaluate(fc.Formula2)
Select Case fc.Operator
' etc
bln = true if relevant condition met in case's
why < 3 (xlEqual), cos only then have Formula2
It's well over a year since I wrote this and forgot all the intricacies.
Apart from the obvious that's in common to all similar functions, mine is
very different from Chip's or any other I've seen. It's not though a UDF and
as such has the luxury to cater for other problems, such as relative vs
absolute addressing in multicell ranges.
In your post that I first replied to, you did clearly stated the problem. As
I've already said I misread, or rather didn't twig. That's despite having
spent some considerable time on a similar function. In mitigation, I
recalled reading your earlier posts in which you had not described the
problem. Namely, in particular respect to the formula in comparison vs
expression. Very difficult for most readers to have picked up on, even those
who have worked with format conditions. You very much gave the impression of
not having read Chip's instructions, eg
"
There is an undefined function in the demo code.
GetStrippedValue(cellReference as Range)
Makes it really hard to try out a 'solution' if something is missing.
"
Hence the frustrating dialog that ensued!
Anyway, got there in the end. And wouldn't take much to have adapted Chip's
for your requirements.
Regards,
Peter T
MarkTheNuke said:
You don't even have to enter a formula, if you enter a cell reference it will
fail because it performs a string comparision on the cell address instead of
getting the value of the referenced cell. If you use the Evaluate Method,
you have to use the worksheet object as the calling reference, since if you
do use cell addresses they are not resolved to their correct worksheet. You
can't enter Sheet2!$A$1 as a conditional value, but you can enter $A$1.
Like I said, a lot of what I did was refactor the code that Chip provided.
Also I did paste Chip's code into an excel spreadsheet, unfortunately it did
fail when I used my first address.
Peter T said:
Perhaps I did misread, quoted from from your previous post:
you can enter a formula into the value comparison routines, which means you
would have to use the Evaluate Method for the value comparison routine
I've never thought to do that - enter a formula to be compared. Quite
unusual. In which case simple enough to amend Chip's functions. Along the
lines that if the first character in the string is an "=" it's probably a
formula that's best evaluated.
In ActiveCondition, under Temp2 = GetStrippedValue(FC.Formula2) there's an
if/else. Add an extra Elseif to check that "=" and Evaluate. Would also need
a bit more checking.
Regards,
Peter T.
Peter T said:
Comments in line:
maybe you misread my original question, or I was not clear
Could be either / or. Let's find out -
and like I said the big thing I was looking for was whether
ConditionalFormatting should have been applied
Assuming you are looking at single cell A1 you would enter
=ActiveCondition(A1)
This will return 0 (no conditions are true) or 1 to 3 to indicate which of
the three conditions are true. Doesn't that fullfill the requirement?
actually I was looking if it was applied,
Not quite sure what you mean here unless you want to return the ColorIndex
of Fill or Font that been applied relates to a true condition, or the
underflying index if no conditions are true (btw - a function very
adaptable to own needs)
=ColorIndexOfCF(A1,false)
Have you put all Chip's functions, including the required helper
GetStrippedValue, into a module and tried each.
What have I missed?
Regards,
Peter T
Yes, Chip does use Evaluate for the expression type of format conditions,
however, if you play around with conditional formatting, you can enter a
formula into the value comparison routines, which means you would
have
to
use
the Evaluate Method for the value comparison routine. Like I said,
I
was
looking for a specific result, which is why I wrote my own
spreadsheet.
I
did not mean to disparage Chips effort, if I did then I apologize.
I
just
made a comment about something I thought was missing.
I did read Chips routines, more than once, and like I said the big
thing
I
was looking for was whether ConditionalFormatting should have been
applied,
actually I was looking if it was applied, but there is no function that
determines that, maybe you misread my original question, or I was not
clear
enough.
:
A few people have tried to point out to you why you were not succeeding
with
Chip's function. And that despite the clear instructions given by Chip.
I'll
have a go as well because, having just read your link to your page, I
was
amazed to see your comment:
"I was suprised that the author [Chip] did not use the Evaluate Method"
I've seen various functions relating to Format Conditions, and written
one
of my own (some different features to anything I've seen). They
all
use
Evaluate, including of course Chip's.
Could I suggest as others have that you carefully read Chip's page in
full,
together with previous advice given in this thread. Re-read repeatedly
until
the light dawns. It will
Regards,
Peter T
Yes, I did look at the Chip Pearson site. I have finished my
VBA
code
for
determining if ConditionalFormatting is applied. You can view the
results
at:
http://home.comcast.net/~mgillesp/ConditionalFormatting.htm, if you
have
any
questions or comments you can post them to this message.
:
Did you look at Chip Pearson's site (previously mentioned in this
thread)?
Chip Pearson shows a way:
http://cpearson.com/excel/CFColors.htm
MarkTheNuke wrote:
Well it looks like there is no way of programatically determining
if
conditional formatting is applied, the best to be hoped for is
determining if
conditional formatting should be applied based on the
contents
of
the
cell
and the conditional formatting conditions. I have it all in a
spreadsheet, I
will provide a link once I get it onto my web pages. (In
about
2
years)
:
LOL
--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03
--------------------------------------------------------------------------
--
It's easier to beg forgiveness than ask
permission
-------------------------------------------------------------------------- think
I
might have
found a cleaner solution using the Evaluate Method. However,
it
still
does
not answer my question about determined if Conditional
Formatting
is
applied,
I guess the answer is you can't, except by visual examination.
Mark
<snip>