Macro to highlight a row if cells match value [Solved/Closed]

- - Latest reply:  sgriffis - Feb 22, 2011 at 10:29 AM
Hello,

I sorry but I am very new to macros and trying to create one in Office 2003. I need to bold a row if for example column E is greater than a given value and column H is today's date or earlier.

So if Column E >= 50 AND column H is today or an earlier date then bold that row.

Any help is appreciated.

Thanks!
See more 

2 replies

Best answer
Posts
2435
Registration date
Sunday September 12, 2010
Status
Contributor
Last seen
December 4, 2018
2
Thank you
Hi Sgriffis,

Try this code:

Sub test()
Set MR = Range("E1:E100")
For Each cell In MR
If cell.Value >= 50 And cell.Offset(0, 3).Value <= Date Then cell.EntireRow.Font.Bold = True
    Next
End Sub

You stated that you are very new to VBA so here's how to implement the code:

In excel goto top menu > extra > macro > visual basic editor (or ALT F11).
A new window will open, goto top menu > insert > module.
Copy the code in the big white field.
Adjust the name "test" to whatever name you want to give this macro.
Adjust the range ("E1:E100") to whatever range you use in your file.
You can now close the visual basic editor window.
Back at excel goto top menu > extra > macro > macro's (or ALT F8).
Choose to run the macro "test" or whatever name you changed it into.

Note: Actions made by macro cannot be undone using the blue arrows!
So it is always best to save before running a macro, if the desired result doesn't show up you can simply reload your file.

Best regards,
Trowa

Thank you, TrowaD 2

A few words of thanks would be greatly appreciated. Add comment

CCM has helped 2601 users this month

0
Thank you
Perfect, thanks!