简体   繁体   中英

recognize a interior highlight

Okay so I´m trying to recognize everything highlighted with the Dark Blue text 2 lighter 60% and for each value where its true in my range I want to make the cell 2 spaces to the right = 1. I have the below code, any ideas?

Sub findcolor()
Dim cl As Range

For Each cl In Workbooks("Report").Worksheets("sheet1").Range("A1:B10")
 If cl.Interior.Pattern = xlSolid And cl.Interior.PatternColorIndex = xlAutomatic And cl.Interior.ThemeColor = xlThemeColorLight2 And cl.Interior.TintAndShade = 0.599993896298105 And cl.Interior.PatternTintAndShade = 0 Then
        cl.Offset(0, 2).Value = "1"
    End If
Next cl
End Sub

Click:
Fill Color icon on the tool bar, and select your color then
More Colors from the submenu and custom tab
now , you can see the three values that make up an RGB(Red, Green, Blue) object for the color you chose
Instead of using all the arguments like you have done - simply use the RGB object with the three values

Sub findcolor()
    Dim cl As Range
    For Each cl In Worksheets("Sheet1").Range("A1:B10")
        If cl.Interior.Color = RGB(141, 180, 226) Then
            cl.Offset(0, 2).Value = "1"
        End If
    Next cl
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM