» Set up conditional formatting for an area with VBA in Microsoft Excel
CATEGORY - Formating in VBA
VERSION - All Microsoft Excel Versions
Question: In the selected area, the maximum value is to be marked violet with a conditional formatting
Answer:
Enter following code in a standard module.
Sub ConditionalFormat()
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=" & Range("Field").Cells(1).Address(False, False) & _
"=MAX(" & Selection.Address & ")"
.FormatConditions(1).Interior.ColorIndex = 39
End With
End Sub
Book Store:
Recommended Books:
- Microsoft Outlook Version 2002 Step by Step (With CD-ROM)
- The McGraw-Hill 36-Hour Course in Finance for Nonfinancial Managers
- Good to Great: Why Some Companies Make the Leap... and Others Don't
- Absolute Beginner's Guide to Microsoft Office Excel 2003
- Essentials of Investments with Standard & Poor's Educational Version of Market Insight + PowerWeb + Stock Trak Coupon
- Special Edition Using Microsoft Word 2002
No comments have been submitted.

