Is there any option to highlight the whole row when a cell is selected? That means when i move from one cell to another, I expect the whole row that contains the second cell to be highlighted. It would be very helpful for me to work on sheets with larger number of columns.
Right click on your sheet and select View-> Code. Enter this code in there -Now save your file and come back to the sheet. Whichever cell you click on, the row will be highlighted.Private Sub Worksheet_SelectionChange(ByVal Target As Range) Rows(Target.Row & ":" & Target.Row).Select End Sub
Cheers,
Arlette
If I helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
That code will highlight the whole row because it is selected. Not a good option if you actually want to work with the cell tht was originally selected
Worksheet event code is stored on a worksheet module. To add it to your worksheet, do the following:Option Explicit Const iNoColour As Integer = Not (0) Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim iColour As Integer ' Note: Don't use IF you have Conditional formating that you want to keep! On Error Resume Next iColour = Target.Interior.ColorIndex ' Leave On Error ON for Row offset errors If iColour < 0 Then iColour = 34 Else: iColour = iColour + 1 End If ' Need this test in case Font colour is the same If iColour = Target.Font.ColorIndex Then iColour = iColour + 1 Cells.FormatConditions.Delete ' Horizontal colour highlight With Target .EntireRow.FormatConditions.Add Type:=2, Formula1:=iNoColour 'Or just 1 '"TRUE" .EntireRow.FormatConditions(1).Interior.ColorIndex = iColour End With End Sub
Copy the code
Select the worksheet in which you the code to run
Right click on the sheet tab and choose View Code, to open the Visual Basic Editor.
Where the cursor is flashing, choose Edit | Paste
Last edited by royUK; 01-14-2012 at 01:49 PM.
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks