Consulting

Results 1 to 10 of 10

Thread: Conditional formatting

  1. #1
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location

    Question Conditional formatting

    how can I obtain the values of the conditional formatting of an ActiveCell using VBA??

    Preferrably placed in a MsgBox.




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  2. #2
    VBAX Mentor Justinlabenne's Avatar
    Joined
    Jul 2004
    Location
    Clyde, Ohio
    Posts
    408
    Location
    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..
    Justin Labenne

  3. #3
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    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
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  4. #4
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    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




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  5. #5
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    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,
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  6. #6
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Quote Originally Posted by kpuls
    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





    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  7. #7
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    and be sure to click on the top link...I can't seem to get rid of that last "xls" link ???




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  8. #8
    VBAX Mentor Justinlabenne's Avatar
    Joined
    Jul 2004
    Location
    Clyde, Ohio
    Posts
    408
    Location
    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.
    Justin Labenne

  9. #9
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    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
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  10. #10
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Quote Originally Posted by TonyJollans
    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
    Figures
    Eh, I'll figure it out. Thanks anyway.




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •