chazzerman01
Board Regular
- Joined
- Nov 18, 2019
- Messages
- 65
does anyone know a macro code that will highlight the whole row that the cursor is on. im using it to make it easier to read values in a table
Public OldTarget As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cell As Range
On Error Resume Next
For Each cell In Range(Cells(OldTarget.Row, "A"), Cells(OldTarget.Row, "O"))
cell.Interior.Color = Cells(100000, cell.Column).Interior.Color
If cell.Interior.Color = 16777215 Then
With cell.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next cell
Range(Cells(Target.Row, "A"), Cells(Target.Row, "O")).Interior.Color = RGB(255, 255, 0)
Set OldTarget = Target
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = True
End Sub
its started doing it with kokoseks one as well now, whenever I click on a cell it just come up on the macro ambiguous name detected: worksheet_selectionchangeCare to elaborate on that? It works for everyone else, just maybe less preferable if you focus on aesthetics.
Public OldTarget As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cell As Range
If Not Intersect(Target, [A:O]) Is Nothing Then ' change here for which range of columns macro has to react
On Error Resume Next
For Each cell In Range(Cells(OldTarget.Row, "A"), Cells(OldTarget.Row, "O"))
cell.Interior.Color = Cells(cell.Row + 1, cell.Column).Interior.Color
If cell.Interior.Color = 16777215 Then
With cell.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next cell
Range(Cells(Target.Row, "A"), Cells(Target.Row, "O")).Interior.Color = RGB(255, 255, 0)
Set OldTarget = Target
End If
End Sub
You can only have one worksheet_selectionchange code in your worksheet.it just says ambiguous name detected: worksheet_selectionchange