VBA - Coloring Rows Instead of Cells

G

Guest

Please Help!

I'm using the following in VBA:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer

If Not Intersect(Target, Range("A6:n2000")) Is Nothing Then
Select Case Target
Case 15
icolor = 4
Case -15
icolor = 46
Case 100
icolor = 6
Case -100
icolor = 3
Case Else
'Whatever
End Select

Target.Interior.ColorIndex = icolor
End If

End Sub

It change the color in that cell but I want it to color the row from coulums
A to N? Can somebody show me how to do that?
 
G

Guest

Simply add a loop using the targets row property:


For myloop = 1 To 14
ActiveSheet.Cells(Target.Row, myloop).Interior.ColorIndex = icolor
Next
 
P

PCLIVE

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer

If Not Intersect(Target, Range("A6:n2000")) Is Nothing Then
Select Case Target
Case 15
icolor = 4
Case -15
icolor = 46
Case 100
icolor = 6
Case -100
icolor = 3
Case Else
'Whatever
End Select

Stop
Target.EntireRow.Interior.ColorIndex = icolor
End If

End Sub
 
G

Guest

Excellent! Thank you Dom_Ciccone.

Dom_Ciccone said:
Simply add a loop using the targets row property:


For myloop = 1 To 14
ActiveSheet.Cells(Target.Row, myloop).Interior.ColorIndex = icolor
Next
 

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