PDA

View Full Version : [SOLVED:] Conditional formatting



malik641
08-05-2005, 06:21 PM
how can I obtain the values of the conditional formatting of an ActiveCell using VBA??

Preferrably placed in a MsgBox.

Justinlabenne
08-05-2005, 07:30 PM
You want to know what type of conditional formatting is used on the activecell?

I don't know of a way right off to put it into a message box, but why not just run this that brings up the Conditional formats dialog, it will display whatever format (if any) that cell has:


Option Explicit

Sub GetConds()
Application.Dialogs(xlDialogConditionalFormatting).Show
End Sub

I have a strong feeling that I am misinterpreting your question though..

Ken Puls
08-05-2005, 07:32 PM
Could try something like this, but as Justin says, it kind of depends what you want to see...


Sub test()
Dim cl As Range
Set cl = ActiveCell
Dim l As Long
For l = 1 To cl.FormatConditions.Count
MsgBox cl.Address & " is between " & cl.FormatConditions.Item(l).Formula1 & _
" and " & cl.FormatConditions.Item(1).Formula2 & vbNewLine & _
" and applies a color index of " & cl.FormatConditions.Item(1).Interior.ColorIndex
Next l
End Sub

malik641
08-05-2005, 08:48 PM
I can try to work with what both you guys gave me. Justin's won't work on my worksheet because it is protected and I don't have the password.

How do I get WHICH .Item(#) it is?? I don't even know if it uses the "cell between" or the "formula is" conditions...

UNLESS of course you guys know how to obtain the worksheet password :devil:

Ken Puls
08-05-2005, 08:56 PM
So... should we ask why you're trying to figure out what the conditional formatting is on a protected sheet for which you don't have the password? :)

Honestly, we could remove the worksheet password, but I'd rather not do that.

What you could do is step through the macro one line at a time. Make sure you have the Locals window open. Drill down through cl (once it has a plus sign beside it) and drill into the FormatConditions property. You should be able to expose everything you need.

HTH,

malik641
08-05-2005, 09:13 PM
So... should we ask why you're trying to figure out what the conditional formatting is on a protected sheet for which you don't have the password? :)Yeah, you can ask. You may have seen this in HTML format, OR you may have been forwarded this Workbook. It displays images of movies, except the people in the pictures are invisible. And you have to guess what movie each picture is from. It's pretty cool, but I'm getting frustrated at some of these and I want to know the answers (so I thought I could sneak around the program to figure it out).

Check it out, the file was too large. So here is the link:
http://uk.download.yahoo.com/ne/fu/attachments/namethatfilm1c.xls (http://nameThatFilm)

(http://uk.download.yahoo.com/ne/fu/attachments/namethatfile1c.xls)

malik641
08-05-2005, 09:18 PM
and be sure to click on the top link...I can't seem to get rid of that last "xls" link ???

Justinlabenne
08-06-2005, 05:01 AM
These kinds of tests usually have a hidden formula (Like in a cell behind the picture) to read what you put in for the answer. The conditional formatting will adjust based on the formula result.

TonyJollans
08-06-2005, 05:01 AM
Getting the conditional formatting (which you can do in the VBE) won't help you.

You will need to crack the security .. or know your films :D

malik641
08-07-2005, 07:59 AM
Getting the conditional formatting (which you can do in the VBE) won't help you.

You will need to crack the security .. or know your films :DFigures :mkay
Eh, I'll figure it out. Thanks anyway.