Excel - automatically row highlight like manualy highlighted

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try this code as a test. It highlights the selected cell row from column B to G within the Range("B8:G25).
This is easily enlarged as needed.

Copy and paste code in sheet module.

Regards,
Howard

Code:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Data As Range
Dim i As Integer
Dim k As Integer
i = 2
k = ActiveCell.Column()
Set Data = Range("B8:G25")
Data.Interior.ColorIndex = xlNone
If ActiveCell.Row < 8 Or ActiveCell.Row > 25 Or _
    ActiveCell.Column < 2 Or ActiveCell.Column > 7 Then
       MsgBox "Out of range", vbOKOnly, "Booger Snot" & " !" & " !"
    Exit Sub
End If
ActiveCell.Offset(0, -(k - i)). _
  Resize(1, 6).Interior.ColorIndex = 35
End Sub
 
Last edited:
Upvote 0
try below code in worksheet module it will highlight selected cell row
Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
 Rows.Interior.ColorIndex = 0
 Target.EntireRow.Interior.ColorIndex = 6
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,246
Members
449,075
Latest member
staticfluids

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