Highlighting the content of a full row makes it very convenient to peruse and go through the content of that row especially for tasks such as data validation.
Here is a cool approach for temporarily highlighting the content of an entire row whenever any cell within that row is selected. Consider the data set below. The goal is to highlight a row whenever any cell in that row is clicked on and then remove the highlighting on the second click.
STEP 1] Make sure that the spreadsheet is saved as a “Macro Enabled workbook”.
STEP 2] Right click on the specific tab and go to “View Code”.
STEP 3] Paste the following code under the sheet that you want to apply the highlighting to.
Private Sub Worksheet_SelectionChange(ByVal SelectedCell As Range) If SelectedCell.EntireRow.Interior.Color = vbYellow Then SelectedCell.EntireRow.Interior.ColorIndex = xlNone Else SelectedCell.EntireRow.Interior.Color = vbYellow End If End Sub
STEP 4] Save and close the macro window. Now the code could be tested. Clicking on each cell will highlight the entire cell and clicking on it again will remove the highlighting.
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
CategoriesArchives
June 2020
|