Thread: Colour rows
View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
excelent excelent is offline
external usenet poster
 
Posts: 695
Default Colour rows

Do u mean color from B to M or trick in B to M ? (this one trick)
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B12:M2000")) Is Nothing Then Exit Sub
If Target = "FU" Then Target.EntireRow.Interior.ColorIndex = 4
If Target = "FR" Then Target.EntireRow.Interior.ColorIndex = 46
If Target = "SU" Then Target.EntireRow.Interior.ColorIndex = 6
If Target = "PE" Then Target.EntireRow.Interior.ColorIndex = 3
If Target = "NS" Then Target.EntireRow.Interior.ColorIndex = 2
If Target = "CL" Then Target.EntireRow.Interior.ColorIndex = 9
If Target = "" Then Target.EntireRow.Interior.ColorIndex = xlNone
End Sub

"John D" skrev:

I have worked out what was happenning and it works beautifully now thanks
very much.
However now I would like to limit it to a range of columns that is from B to
M any ideas how to do this?

"John D" wrote:

Thanks for the advice it sort of works that is it has colored the lines but
doesn't readily change the color. When debugging it comes up with
run time error '13'
type mismatch
and it highlights If Target = "FU" Then
Sorry I don't understand
"excelent" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("G12:G2000")) Is Nothing Then Exit Sub
If Target = "FU" Then Target.EntireRow.Interior.ColorIndex = 4
If Target = "FR" Then Target.EntireRow.Interior.ColorIndex = 46
If Target = "SU" Then Target.EntireRow.Interior.ColorIndex = 6
If Target = "PE" Then Target.EntireRow.Interior.ColorIndex = 3
If Target = "NS" Then Target.EntireRow.Interior.ColorIndex = 2
If Target = "CL" Then Target.EntireRow.Interior.ColorIndex = 9

End Sub


"John D" skrev:

I have tried the following code which was in "VBA - Coloring Rows Instead of
Cells" question earlier however it doesn't work for me so maybe I have done
something wrong.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer

If Not Intersect(Target, Range("G12:G2000")) Is Nothing Then
Select Case Target
Case "FU"
icolor = 4
Case "FR"
icolor = 46
Case "SU"
icolor = 6
Case "PE"
icolor = 3
Case "NS"
icolor = 2
Case "CL"
icolor = 9
Case Else
'Whatever
End Select

Target.EntireRow.Interior.ColorIndex = icolor
End If

End Sub






"John D" wrote:

I have never used VBA so this might be very basic. I have an excel
spreadsheet and on it is a column that the user can place different initials
to indicate status of client e.g. FU; FR; SU; PE and so on. I am wanting if
its possible to have excel colour the row with a different colour for each
variation.
Can anyone suggest anything please?