View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary''s Student
 
Posts: n/a
Default Conditional Formatting

This can be accomplished by using the worksheet change event. The following
macro monitors changes in A1:A20 and set the background colour:

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("A1:A10"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Select
i = Selection.Value
With Selection.Interior
.ColorIndex = i
.Pattern = xlSolid
End With
Application.EnableEvents = True
End Sub

The sample macro only works with integers and assigns colours based upon the
integers. You could modify it to operate in a more general way.
__________________Have a good day!
Gary's Student


"Ian.UK" wrote:

Hi,

Is it possible to introduce more than 3 conditions (via conditional
formatting) onto a single spreadsheet?

I have a spreadsheet with 9 columns - the first is for name, then 1st
choice, 2nd choice etc etc...up to 8th choice. There are 8 different things
that could appear in each cell on the same row - and I would like the cell to
change colour automatically according to what appears in it. This would
obviously require 8 conditions - but I seem limited to 3.

Is there a way to increase the number of permissible conditions, or can
anyone think of a way I can achieve this without conditions?

Thanks,

Ian