Traditional Culture Encyclopedia - Almanac inquiry - Vba code about the color change of the whole line of excel.

Vba code about the color change of the whole line of excel.

According to the current situation, to achieve this effect, we can only use VBA to achieve it. Here are the methods, please have a look.

As shown below, this is the effect under normal circumstances. When we select a cell, only the border color of the cell has changed, while the other cells in the row have not changed.

Now, what we need to do is, as shown in the figure below, once a cell is selected, the color of the row where the cell is located will change, which is convenient for us to input data.

To do this, right-click the worksheet name (for example, Sheet 1) and select View Code in the shortcut menu that pops up, as shown below!

Next, VBA coding window will pop up, as shown below!

five

In the above figure, right-click Sheet 1 and select View Code to open the code writing window.

Now, all we have to do is input VBA function code, as shown above! Remember, first select the name of the worksheet object and the name of the SelectionChange event, and then enter the code on the right side of the window as shown above.

For your convenience, please paste the following source code:

Private worksheet _ selection change (byval target as range)

rows()interior . colorindex = 0。

x = ActiveCell。 row

rows(x)。 interior。 colorindex = 9

End joint