Color a cell When Change Is Made

Z

Zorro

I have used the following:

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Interior.ColorIndex = 8
End Sub

But what I really want to do is to color the entire row in one color and the
changed cell in another.

Any code out there please?

TIA
Zorro
 
G

George Nicholson

Private Sub Worksheet_Change(ByVal Target As Range)
Target.EntireRow.Interior.ColorIndex = 37
Target.Interior.ColorIndex = 8
End Sub

HTH,
 
C

Chip Pearson

I would add a safeguard to ensure that Target is only one row tall.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Rows.Count = 1 Then
Target.EntireRow.Interior.ColorIndex = 37
Target.Interior.ColorIndex = 8
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
Z

Zorro

Thanks for that. One problem though. I can only highlight one change per row
using the code below. Is there a way to highlight a number of cells on the
same row as they are changed. They may not neccessarily be contiguous.

Private Sub Worksheet_Change(ByVal Target As Range)
Target.EntireRow.Interior.ColorIndex = 3
Target.Interior.ColorIndex = 8
End Sub

Cheers
Zorro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top