ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Morning,
Maybe you could assist me please.
I have the following code supplied below.
The code at present works for rows 29 & 30 but im thinking of it also needs to work for rows 4 to 28 but another color.
is this possible please & could you advise how / where i need to apply the additional info.
Have a nice day.
Maybe you could assist me please.
I have the following code supplied below.
The code at present works for rows 29 & 30 but im thinking of it also needs to work for rows 4 to 28 but another color.
is this possible please & could you advise how / where i need to apply the additional info.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myStartCol As String
Dim myEndCol As String
Dim myStartRow As Long
Dim myLastRow As Long
Dim myRange As Range
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
' *** Specify columns to apply this to ***
myStartCol = "A"
myEndCol = "G"
' *** Specify start row ***
myStartRow = 29
' Use first column to find the last row
myLastRow = 30
' Build range to apply this to
Set myRange = Range(Cells(myStartRow, myStartCol), Cells(myLastRow, myEndCol))
' Clear the color of all the cells in range
myRange.Interior.ColorIndex = 2
' Check to see if cell selected is outside of range
If Intersect(Target, myRange) Is Nothing Then Exit Sub
' This color will Highlight the row
Range(Cells(Target.Row, myStartCol), Cells(Target.Row, myEndCol)).Interior.ColorIndex = 3
' This color will Highlight the cell in the row
Target.Interior.Color = vbRed
Application.ScreenUpdating = True
End Sub
Have a nice day.