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.
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.