View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Udo Udo is offline
external usenet poster
 
Posts: 48
Default conditional formatting

Hi,

as Excel only accepts three conditions for cond. formatting, you have
to use a VBA solution:
Sub RangeFormatting()

Dim RangEl As Range
Dim Area As String
Dim Message As String
Dim LF As String

LF = Chr(10) 'line feed
Message = "Please enter the range to be coloured" + LF + _
"The form is e.g. B8:C25"

Message = InputBox(Message, "Range entry")
Range(Message).Select
Selection.FormatConditions.Delete
For Each RangEl In Selection
Debug.Print RangEl.Value
Select Case RangEl.Value
Case Is < 0.2
RangEl.Font.ColorIndex = 2
RangEl.Interior.ColorIndex = 9
Case Is < 0.25
RangEl.Font.ColorIndex = 2
RangEl.Interior.ColorIndex = 44
Case Is < 0.35
RangEl.Font.ColorIndex = 2
RangEl.Interior.ColorIndex = 50
Case Is < 0.4
RangEl.Font.ColorIndex = 2
RangEl.Interior.ColorIndex = 44
Case Is 0.4
RangEl.Font.ColorIndex = 2
RangEl.Interior.ColorIndex = 9
End Select

Next

Cells(1, 5).Select

End Sub

Hope that helps.
If you need support re. how to activate this, just ask.

Good luck
Udo



dinadvani via OfficeKB.com schrieb:

Hello,

I am facing problems with conditional formatting.

I need the below to be done, please help -

1) Ask the user on which he wants to apply the conditional formatting
2) Once user selects the range, then apply conditional formatting on it.
3) Below are the 5 conditions
a) 25 to 35 % - Interior colour green and font colour white
b) 20% to 25 % - - Interior colour gold and font colour white
c) 35 to 40% - - Interior colour gold and font colour white
d) below 20 % - - Interior colour red and font colour white
e) above 40%- Interior colour red and font colour white


Please help me to perform this.

Thanks for your help

D

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200611/1