Test for Color

sachavez

Active Member
Joined
May 22, 2009
Messages
469
Excel 2003

Need code to look at range F10:F21 and determine if any cells in the range are yellow. If "true," need cell F2 to turn yellow and include message saying "True."

Can you help?

Thanks
 
I wasn't sure if I could change Value, so I added Value2. I updated the code to use Value.

The code doesn't work if cell F10 contains "Repair needed - non Roadable" and F11 contains any other text. F2 is clear.

Here's updated code:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F10:F21")) Is Nothing Then
    Range("F2").Clear
    If Target.Value = "Repair needed - non Roadable" Then
        With Range("F2")
            .Value = "Flat Bed Truck Required"
            .Interior.ColorIndex = 6
        End With
    End If
End If
End Sub
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I don't understand why that does not work.

Please explain in words exactly what should happen.
 
Upvote 0
The user can enter up to 12 unit numbers in column A and in corresponding rows in column f (range F10:F21), the user selects 1 of 3 options from a dropdown.

If the user selects Repair needed - non roadable in cell F10, the code works fine; however, if the user selects another option in cell F11, the code does not work.
 
Upvote 0
I think that is because IF the last workbook change event does not meet the criteria, the code clears cell F2.

Thoughts???
 
Upvote 0
So, if the users' option in cell F11 meets the criteria, but their option in cell F12 does not, cell F2 should remain yellow and say Flatbed truck required.

Thanks!!!
 
Upvote 0
Maybe (otherwise I don't know what is wrong)

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F10:F21")) Is Nothing Then
    If Target.Value = "Repair needed - non Roadable" Then
        With Range("F2")
            .Clear
           .Value = True
            .Interior.ColorIndex = 6
            .Value2 = "Flat Bed Truck Required"
        End With
    End If
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,156
Messages
6,183,230
Members
453,152
Latest member
ChrisMd

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