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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

John Davis

Well-known Member
Joined
Sep 11, 2007
Messages
3,457
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
 

jmclaren

New Member
Joined
Feb 18, 2016
Messages
5
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,074
Messages
5,835,232
Members
430,349
Latest member
Gregori

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
Top