Highlighting active row.

sam1791

New Member
Joined
Feb 19, 2011
Messages
8
I wrote a VB command for my whole workbook that when I selected a cell, the whole row would be highlighted. My issue is that everytime I selected a different sheet, the spreadsheet flicker, like it close then open the sheet. The following is my VB command:

Const mStrConst_CFFormula = "ROW(A1)=ActiveRow"
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Call setCF(Sh)
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
With ThisWorkbook.Names("ActiveRow")
.Name = "ActiveRow"
.RefersToR1C1 = "=" & ActiveCell.Row
End With
End Sub
Sub setCF(ByVal oActiveSheet As Object)
Dim oWorkSheet As Worksheet
Dim oCF As FormatCondition

On Error Resume Next
Set oWorkSheet = oActiveSheet
Set oCF = oWorkSheet

If Not oCF Is Nothing Then Exit Sub

On Error GoTo Err_Handler
With oWorkSheet
.Range("A1").Select
.Cells.Select
.Cells.FormatConditions.Add Type:=xlExpression, Formula1:=mStrConst_CFFormula
End With

With oWorkSheet.Cells.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.14996795556505
End With
Exit Sub

Err_Handler:
MsgBox Err.Description, vbInformation

End Sub

Also, does any one know the shade code. I wants to use light blue instead of gray.

Thanks.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Thanks Peter. However, I was unable to understand the steps to identify the color code. Would you show me how? Thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,480
Members
452,915
Latest member
hannnahheileen

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