In Excel, in order to enhance the contrast of the active cell, sometimes we need to modify its background color, font, font size, and so on, to differentiate and other cell contrast!
In this tutorial, let's learn how to make Excel active cells have the background color in rows and columns, first look at the figure below.
In the picture above, that is, C3 cell, is selected by the mouse, indicating that the active cell, how to do as shown above, C3 active cell row and column, the background color is color, so that we can easily observe the cell, the correct input data.
This has to be done using VBA code, as follows:
First in the Excel window, press the key combination on the keyboard: Alt + F11
This time, the VBA window pops up.
① Right-click the Sheet1 in the left list and check the code. This will pop up a small VBA input window.
② in the small window above, select Worksheet name on the left, select SelectionChange event on the right. Here's where you can enter the code, as follows:
Private Sub Worksheet_selectionchange (ByVal Target as Range)
Columns (). Interior.ColorIndex = 0
x = Activecell.column
Columns (x). Interior.ColorIndex = 13
y = ActiveCell.Row
Rows (y). Interior.ColorIndex = 13
End Sub
Finally, save the VBA window and close it, and return to the Excel window, the effect comes out.
Knowledge Extension:
Part of the code explains:
Columns (). Interior.ColorIndex = 0
x = Activecell.column
Columns (x). Interior.ColorIndex = 13
The function of the code above is to have the code with the background color listed on the active cell.
y = ActiveCell.Row
Rows (y). Interior.ColorIndex = 13
The function of the code above is the code that keeps the active cell in the background color of the row.