Skip to main content
1 of 4
Mr.Burns
  • 237
  • 2
  • 9

VBA Excel - Conditional Formatting Colour Grab

Sub myCFtest()

For q = 1 To 26

sCol = Split(ActiveCell.Address, "$")(1)
sColNum = sCol & 1
Range(sColNum).Select

For i = 1 To 100

sColNum = ActiveCell.Address

    If Range(sColNum).DisplayFormat.Interior.Color = 255 Then
        Y = ActiveCell.Address
        MsgBox ("Red Cell Found At " & Y)
    End If

ActiveCell.Offset(1, 0).Select

Next i

ActiveCell.Offset(0, 1).Select

Next q

MsgBox ("No Red Cell Found")

End Sub

This currently gets the cells colour regardless if it is set from condtional formatting or not, currently works on 2010 and unsure about older versions of excel.

My question is is there a way to make this code more efficent?

  • Such as being able to highlight an area for the code to search rather than setting For stantments

  • Getting it to search for a specific colour you set rather than red or what ever has been set

  • Anything else anyone can think of

Mr.Burns
  • 237
  • 2
  • 9