Link to home
Start Free TrialLog in
Avatar of Jean-Christophe GALLAND
Jean-Christophe GALLANDFlag for France

asked on

Macro for conditional formating in Excel

Hello experts,

I have in a excel file:

-      A target value in C1
-      A table A4:D406
-      values for each row in column D. These values are sorted from lowest to greatest (so D4<D5<D6…)

I would like a macro that formats all the data in the range ‘An:Dn’ in ‘bold red’, with n being the row number where Dn<=C1

Thanks
Avatar of Roy Cox
Roy Cox
Flag of United Kingdom of Great Britain and Northern Ireland image

Why use VBA? Conditional Formatting should do that without VBA
Avatar of Jean-Christophe GALLAND

ASKER

It will help me learn VBScript and I can copy and paste in other files

I believe you can do this with Conditional Formatting.  Selecting Column D and using conditional formatting to look for cells <= C1.  The only disadvantage is the highlighting is only column D.  So if it is important to highlight A:D maybe this won't work.
Sorry my comment didn't see your responses.
VBScript is not the same as VBA. I see no point in VBA for this, you can copy and paste formats to another workbook.

By all means learn VBA, but don't use it pointlessly.

If you don't want to respect my request, your choice... Always amazed that people spend more time challenging customers requests than addressing them. I know exactly what I want and I don't need to further justify. And yes, maybe VBA is the correct term

Sure.  Think most of the experts comments are to help clarify the request.  Sometimes a question is not completely clear, or perhaps the author is not aware of other alternatives.  In your case you clear about what you want.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I’m glad I was able to help.

If you expand the “Full Biography" section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2019
              Experts Exchange Top Expert VBA 2018, 2019
              Experts Exchange Distinguished Expert in Excel 2018