IF statement for fill color?

paquirl

Board Regular
Joined
Oct 12, 2010
Messages
226
Office Version
  1. 2016
Platform
  1. Windows
After filtering a column for a fill color yellow:

Code:
ActiveSheet.Range("$A$1:$AB$1217").AutoFilter Field:=11, Criteria1:=RGB(255 _
        , 255, 0), Operator:=xlFilterCellColor

I want to then do an IF THEN logic command as follows: IF no yellow filled cells exist in Field:=11, THEN skip to another step (4 steps down). Can anyone help me figure out how to do this IF THEN command?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
try this:

Code:
Sub step4down()

Dim CountCcolor As Long
Set range_data = Range("$K$1:$K$1217")

For Each x In range_data
    If x.Interior.Color = RGB(255, 255, 0) Then
        CountCcolor = CountCcolor + 1
    End If
Next x

If CountCcolor = 0 Then GoTo step4down Else ActiveSheet.Range("$A$1:$AB$1217").AutoFilter Field:=11, Criteria1:=RGB(255 _
        , 255, 0), Operator:=xlFilterCellColor _
    
step1down:
    
step2down:

step3down:

step4down:
MsgBox "4 Steps Down"

End Sub
 
Upvote 0
I'm trying to comprehend what you wrote lol
 
Upvote 0
i wish there were a way to number each line of code so i could do an if statement to say jump to line X if certain criteria is met.
 
Upvote 0
i get it now .. i'm not supposed to post across two different forum sites. did not know that, sorry
 
Upvote 0
I have abandoned the other post so there's no cross-posting on this topic now.
Joris, what do you think of modifying your idea a little. Instead of doing the stepdown, I decided it would be easier on our end to just make the subroutine end of there is no yellow. So the IF statement would just be, IF yellow-filled cells exist, filter for them. IF no yellow-filled cells exist in the column, do not perform a filter, just END SUB

Potentially this could be done before the filter process? Or does the filter method have to be used to determine IF yellow-filled cells are present in the column?

Seems like the cleanest logic would be:
IF no yellow-filled cells in column X, THEN END SUB
IF yellow-filled cells do exist in column X, filter for them.
 
Last edited:
Upvote 0
Trying to figure out the cleanest order of logic here ...
 
Upvote 0

Forum statistics

Threads
1,215,049
Messages
6,122,864
Members
449,097
Latest member
dbomb1414

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