View Single Post
 
Old 05-20-2017, 06:31 AM
codeghi codeghi is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Jan 2010
Posts: 38
codeghi is on a distinguished road
Default

Quote:
Originally Posted by Pecoflyer View Post
It's not very complicated to add the VBA solution

Open a workbook
Hit Alt+F11 ( VB editor opens)
Clcik View - Project explorer ( it's usually open by default)
Select the sheet where you want to implement the macro
A window opens

Paste this code

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
 
    Application.ScreenUpdating = False
    ' Clear the color of all the cells
    Target.Parent.Cells.Interior.ColorIndex = 0
    With Target
        ' Highlight the entire row and column that contain the active cell
        .EntireRow.Interior.ColorIndex = 8
 
    End With
    Application.ScreenUpdating = True
End Sub
Close the VB window and save when asked
From now on the row will highlight when a cell is selected

Play around with the macro a bit to change the color there where it says
.EntireRow.Interior.ColorIndex = 8
Change the 8 to another value

It works for me and I know nothing about VB


Hello,
I've the same problem.
The VBA solution works, but it deletes the format of the file.
How can be modified the VBA program in order to highlight the row of selected cell without deleting the existing format?
Regards