ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Insert Row colors the complete Row (https://www.excelbanter.com/excel-discussion-misc-queries/178417-insert-row-colors-complete-row.html)

robert morris

Insert Row colors the complete Row
 

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


Mike H

Insert Row colors the complete Row
 
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

"robert morris" wrote:


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


robert morris

Insert Row colors the complete Row
 
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


"Mike H" wrote:

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

"robert morris" wrote:


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


Mike H

Insert Row colors the complete Row
 
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

"robert morris" wrote:

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


"Mike H" wrote:

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

"robert morris" wrote:


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


Don Guillett

Insert Row colors the complete Row
 
Try this to insert
Sub insertrownocolor()
Rows(ActiveCell.row).Insert
Rows(ActiveCell.row).Interior.ColorIndex = 0
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"robert morris" wrote in message
...

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 Phillips

Insert Row colors the complete Row
 
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)



"robert morris" wrote in message
...
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


"Mike H" wrote:

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

"robert morris" wrote:


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




robert morris

Insert Row colors the complete Row
 
Mike,

I corrected the wrap and all is well. Thanks a million/billion!

Bob


"Mike H" wrote:

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

"robert morris" wrote:

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


"Mike H" wrote:

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

"robert morris" wrote:


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



All times are GMT +1. The time now is 03:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com