formatting

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft VBA Training and help » Formatting

Formatting

resolvedResolved · Low Priority · Version 2003

Laura has attended:
Excel Advanced course
Excel VBA Intro Intermediate course

Formatting

Excel only allows 3 condiditonal formats. Is there a way in VBA to have more than this?

RE: Formatting

Hi Laura,

Thank you for your question.

I have typed some code below to show you how to add more than three conditions to a range of cells:

Range("H10:H529").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="=10000", Formula2:="=12000"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ColorIndex = 7
.TintAndShade = 0
End With

If you then copy and paste this code and change the conditions such as the range of the numbers or the Operator(> < etc.)

In the VBA window use Help to see the ColorIndex numbers.

I hope this answers your question.

Tue 1 Sep 2009: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

VBA tip:

Use GoTo to Select A Cell With VBA

To select a certain cell on a Worksheet you can use:

Application.Goto Reference:=Range("V300")

or more simply

Range("V300").Select

If, on the other hand, you want the selected cell to be the top/left cell on the screen you use:

Application.Goto Reference:=Range("V300"), Scroll=True

View all VBA hints and tips


Server loaded in 0.07 secs.