Raja Kamarthi
New Member
Hello Friends,
I have a sheet which has conditional format applied to a set of cells. I applying a VBA script (pls refer below) in this sheet to hightlight the "ACTIVE CELL" but when I am doing so, the current existing conditional format applied for other selected cells gets deleted. Is there a way to fix this?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
End With
.FormatConditions(1).Interior.ColorIndex = 20
End With
End Sub
Thanks
Raja Kamarthi
I have a sheet which has conditional format applied to a set of cells. I applying a VBA script (pls refer below) in this sheet to hightlight the "ACTIVE CELL" but when I am doing so, the current existing conditional format applied for other selected cells gets deleted. Is there a way to fix this?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
End With
.FormatConditions(1).Interior.ColorIndex = 20
End With
End Sub
Thanks
Raja Kamarthi