Saturday, January 10, 2015

How to highlight the row and column of a selected cell in Excel using a VBA macro

To color in red the current row and column of a selected cell, enter following code in the worksheet event "SelectionChange":

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = 0
Rows(Target.Row).Interior.ColorIndex = 3
Columns(Target.Column).Interior.ColorIndex = 3
End Sub




Created by DoMyExcel.com © | Excel & VBA Consulting | Customized Excel Solutions starting at 29 USD
Services provided to Individuals and Businesses | Free Quote: DoMyExcel@gmail.com

No comments:

Post a Comment