Help needed! to check for presence of cell color

fountainwood

New Member
Joined
Jun 15, 2008
Messages
10
I need help here!
I want to create some code that checks all the cells in a row to find if any cell has a background color and if it finds any colored cell, to then set the first column of that row to that color.

desperate!
 
I will have 2 potential colors - yellow and red and they could be in any column in the row. Possibly both colors in the same row, either color or no color.
Column 1 will never be colored initially.

If a color is present, then I would like to set column 1 to be that color - but for red to take precedence over yellow in the situation where both colors might have existed somewhere in the row.

Typically, I have about 40 columns and around 100 rows but the rows will vary up or down.
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
OK........

This works:

Dim c As Range
For Each c In Worksheets("Raw Data").UsedRange
' if deliverable cell is already set to red then no need to check rest of row
If Cells(c.Row, 1).Interior.ColorIndex <> 3 Then
If c.Interior.ColorIndex <> xlNone Then
Cells(c.Row, 1).Interior.ColorIndex = c.Interior.ColorIndex
End If
End If
Next c

The majority of my rows have no color, therefore, it would speed up the process if I could first check the entire row for no color before the need to go check each cell.

So, is there a means to check a row for any fill color without having to navigate each cell ?
 
Upvote 0
If you're using Excel 2002 or later, I'd still recommend using the Application.FindFormat approach I suggested in my first post.

Just run it first for yellow and then for red, as you want red to take precedence if both are present.
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,273
Members
449,219
Latest member
daynle

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