Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Couple of problems here.
First, Cells/Range doesn't have a Color property. For background color, you need to use Select Case Blatt.Cells(i, "K").Interior.Color Second, XL can only display 56 colors at a time, so unless the RGB value is one of the 56 colors in the color palette, it won't match. When you assign an RGB value, XL tries to find the closest match. For instance, when I enter this in the immediate window with the default palette: Cells(1,"K").interior.Color = RGB(128,255,196) ?RGB(128,255,196) 12910464 ?cells(1,"K").interior.color 13434828 ?cells(1,"K").interior.color=RGB(128,255,196) False You're usually better off to use the .ColorIndex property. third, Select Case is an 'expensive' control structure compared to If...Then. It's probably appropriate for the outer Select Case structure, but the inner one would be better off using If...Then: Select Case Blatt.Cells(x, "C").Value Case "critical" If Blatt.Cells(i, "K").Interior.ColorIndex = 35 Then _ xAnz = xAnz + 1 Case "major" yAnz = yAnz + 1 Case "minor" zAnz = zAnz + 1 End Select Or you could use the fact that VBA's True evaluates to -1: Select Case Blatt.Cells(x, "C").Value Case "critical" xAnz = xAnz - (Blatt.Cells(i, "K").Interior.ColorIndex = 35) Case "major" yAnz = yAnz + 1 Case "minor" zAnz = zAnz + 1 End Select In article , "Philipp Oberleitner" wrote: For x = 1 To Blatt.Cells(Rows.Count, "D").End(xlUp).Row Select Case Blatt.Cells(x, "C").Value Case "critical" Select Case Blatt.Cells(i, "K").Color Case RGB(128, 255, 196) xAnz = xAnz + 1 End Select Case "major" yAnz = yAnz + 1 Case "minor" zAnz = zAnz + 1 End Select Next x Cant i use . Color with this context to count lines with a certain rgb background color ? Thx alot |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
change data of entire column from small case to upper case | Excel Worksheet Functions | |||
Case without Select Case error problem | Excel Discussion (Misc queries) | |||
Change the text from lower case to upper case in an Excel work boo | Excel Discussion (Misc queries) | |||
Case Statement error | Excel Programming | |||
Hopefully simple Select Case error | Excel Programming |