Highlighting a row depending on which cell i am clicked on?

chris_streeter

New Member
Joined
Apr 10, 2014
Messages
22
Hi,

Can anyone help me highlight a row depending on what cell I have clicked on?

For example if I am in cell A1 i would like the entire row highlighted, if i then press enter to move to cell A2 i would like the first row to un-highlight and for row 2 to highlight instead?

I think this would be useful in a number of spreadsheets i use.

Cheers :)
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Also if you want a VBA solution this is the best I found

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2
. Click ThisWorkbook

3. In the Window paste the following

Note Column is remarked out so isn't working at the moment as you only requested it to work for rows. If you want it to work for Columns as well remove the ' at the being of the line. If you change the ColorIndex number you get a different color. ColorIndex list try this link Excel Color Palette and Color Index change using VBA | Excel & VBA – Databison

'.EntireColumn.Interior.ColorIndex = 8



Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
' Clear the color of all the cells
Cells.Interior.ColorIndex = 0
With Target
' Highlight the entire row and column that contain the active cell
.EntireRow.Interior.ColorIndex = 8
'.EntireColumn.Interior.ColorIndex = 8

End With
Application.ScreenUpdating = True
End Sub

Cheers
 
Upvote 0

Forum statistics

Threads
1,215,440
Messages
6,124,879
Members
449,192
Latest member
MoonDancer

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top