How to find color index from conditional formatting with vba?

  • I want to clear all of the content on the cell that has color index 15 from VBA, I have tried but it can't be found. But if the cell filled color manually (not from conditional formatting) the vba can find it and clear the content from the cells. Please, help me how to find the color index from CF after that clear content automatically.

  • Re: How to find color index from conditional formatting with vba?


    If you have Excel 2010 or later, you need to use the DisplayFormat property of the Range.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: How to find color index from conditional formatting with vba?


    If you show your code, I'll show you how to change it. ;)

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: How to find color index from conditional formatting with vba?


    I can find the color that filled manually not from CF and it works, but if the cell colored by conditional formatting it doesn't work. here is the code:

  • Re: How to find color index from conditional formatting with vba?


    Use this:

    Code
    Sub CCVALUES()     
        For Each Cell In Range("G1:AK500")
            If Cell.DisplayFormat.Interior.ColorIndex = 15 Then
                Cell.ClearContents
            End If
        Next
         
    End Sub

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: How to find color index from conditional formatting with vba?


    Glad to help. :)

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!