Highlighting active rows

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
21,821
Office Version
  1. 365
  2. 2019
  3. 2013
  4. 2007
Platform
  1. Windows
Hi All
I copied this code from one of Bills Links, but it refuses to work.
It gives an object required error from the second line.
Any clues ??
Regards
Michael M

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim IColor As Integer
On Error Resume Next
IColor = Target.Interior.ColorIndex
  If IColor < 0 Then
   IColor = 36
   Else
       IColor = IColor + 1
   End If
If IColor = Target.Font.ColorIndex Then IColor = IColor + 1
Cells.FormatConditions.Delete
    With Range("A" & Target.Row, Target.Address)
        .FormatConditions.Add Type:=2, Formula1:="TRUE"
        .FormatConditions(1).Interior.ColorIndex = IColor
    End With
    With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _
    Target.Offset(-1, 0).Address)
    .FormatConditions.Add Type:=2, Formula1:="true"
   .FormatConditions(1).Interior.ColorIndex = IColor
   End With
End Sub
 
Last edited by a moderator:

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Running Excel 2000 on Windows 2000 it works perfectly for me with no modifications...but you do have to put the code in the Worksheet code page not the workbook code or a module.
Hope this helps,
Cindy
 
Upvote 0
Ok, Thanks Cindy.
Smitty is posting me a workbook with solutions and examples relating to this issue.

Regards
Michael M
 
Upvote 0
Cindy

Arrgh !!.......I just rebooted for a completely unconnected issue and, yep.
It works fine.
Sometimes I hate windows !!

Regards
Michael M
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,144
Members
448,552
Latest member
WORKINGWITHNOLEADER

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