Macro needed to update cell value based on cell shading or font colour

jmclaren

New Member
Joined
Feb 18, 2016
Messages
5
Hi,

I receive a large spreadsheet that uses cell shading and font colours to indicate if an item is required or expired. It would be a lot easier to review if I had a macro that looked at all the data cells in the worksheet and did the following:

If a cell has no data *and* is shaded, then insert a value of "Reqd"
If a cell has text with a red font, replace the text/value with "Expired"

Unfortunately, I have no idea how to go about creating a macro to do this and any help would be much appreciated.

Thanks
Jim
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
This considers all cells on the Sheet, but it can be confined to a Column.

Code:
Sub jmclaren()
Dim r As Range
For Each r In ActiveSheet.UsedRange
    If r.Interior.ColorIndex = xlNone And r = "" Then r.Value = "Reqd"
    If r.Font.ColorIndex = 3 Then r = "Expired"
Next r
End Sub
 
Upvote 0
This considers all cells on the Sheet, but it can be confined to a Column.

Code:
Sub jmclaren()
Dim r As Range
For Each r In ActiveSheet.UsedRange
    If r.Interior.ColorIndex = xlNone And r = "" Then r.Value = "Reqd"
    If r.Font.ColorIndex = 3 Then r = "Expired"
Next r
End Sub

Wow, quick response :). That worked a treat...just needed to change to "If not(r.Interior.ColorIndex = xlNone) And r = "" Then r.Value = "Reqd""
Many thanks for your help John.
 
Upvote 0

Forum statistics

Threads
1,214,858
Messages
6,121,956
Members
449,057
Latest member
FreeCricketId

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