Insert Row colors the complete Row

  • Thread starter Thread starter robert morris
  • Start date Start date
R

robert morris

I use the following code to highlight the last entry in a row.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F4:Y75")) Is Nothing Then
Range("F" & Target.Row & ":Y" & Target.Row).Cells. _
Interior.ColorIndex = xlColorIndexNone
Target.Cells.Interior.Color = vbYellow
End If
End Sub

Problem is, when a Row is inserted, the complete row is Yellow. I have no
Conditional Formating in use.

All I can figure is, it must be in the code.

Bob
 
Bob,

This should cure the colour the entire row bit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("F4:Y75")) Is Nothing Then
Range("F" & Target.Row & ":Y" & Target.Row).Cells.Interior.ColorIndex =
xlColorIndexNone
Target.Cells.Interior.Color = vbYellow
End If
End Sub

Mike
 
Mike,

Thanks, it get rid of the entire row bit but, I get an error box which says;
Compile Error
Syntax Error

And the line below is highlighted in the code, and it no longer highlights
the last entry anywhere on the sheet.

Range("F" & Target.Row & ":Y" & Target.Row).Cells.Interior.ColorIndex =

Bob
 
Bob,

That's just line wrap, the 2 line below should be one but have wrapped in
the post

Range("F" & Target.Row & ":Y" & Target.Row).Cells.Interior.ColorIndex =
xlColorIndexNone

Mike
 
Try this to insert
Sub insertrownocolor()
Rows(ActiveCell.row).Insert
Rows(ActiveCell.row).Interior.ColorIndex = 0
End Sub
 
NG word wrap. The bit on the next line should be part of that line.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Back
Top