loop not working

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
707
Office Version
  1. 365
  2. 2010
Code:
For i = 9 To finalrow
If Range("k" & i).Interior.Color <> 16777215Then
Range("q" & i).clear
End If

so i have conditional formatting in column K to highlight (yellow) and when i do ?activecell.interior.color in the immediate window for the highllighted, it returns 16777215., which I believe is NOT yellow (clicking another cell thats not highlighted returns the same value)

so, i tried <> vbyellow, but loop still doesnt work (ie cell in column Q does not get cleared if cell in column K is NOt yellow highlight)
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I believe your color 16777215 is actually white
Why not change column K to
VBA Code:
For i = 9 To finalrow
If Range("k" & i).Interior.Color <> vbYellow Then
Range("q" & i).Clear
End If
Next i
 
Upvote 0
ye...I tried ...doesn't seem to work

it's weird how it returns white on the conditionally formatted cell
 
Upvote 0
ye...I tried ...doesn't seem to work
What did you try?
I set conditional formatting with red light color

VBA Code:
?ActiveCell.Interior.Color
 16777215
?ActiveCell.DisplayFormat.Interior.Color
 13551615
 
Upvote 0
Solution
it's weird how it returns white on the conditionally formatted cell
That's because the interior colour of the cell is white, it's just the displayed format (ie the CF) that is yellow, which is why you need to use DisplayFormat as shown by Akuini.
 
Upvote 0
What did you try?
I set conditional formatting with red light color

VBA Code:
?ActiveCell.Interior.Color
16777215
?ActiveCell.DisplayFormat.Interior.Color
13551615
sorry, my earlier reply was to another answer

your solution worked....just had to change to color 65535...thanks!
 
Upvote 0
You're welcome, glad to help & thanks for the feedback. :)
 
Upvote 0

Forum statistics

Threads
1,214,970
Messages
6,122,514
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top