Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If ActiveCell.Offset(-1).Font.Bold = True Then
If ActiveCell.Offset(-1).Column <> 5 Then Exit Sub
Call Color_Row_UP
End If
If ActiveCell.Offset(0, -1).Font.Bold = True Then
If ActiveCell.Offset(0, -1).Column <> 5 Then Exit Sub
Call Color_Row_Left
End If
End Sub
Sub Color_Row_UP()
With Range(ActiveCell.Offset(-1), ActiveCell.Offset(-1, -4)).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Range(ActiveCell.Offset(-1), ActiveCell.Offset(-1, -4)).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.Bold = True
End With
End Sub
Sub Color_Row_Left()
With Range(ActiveCell.Offset(0, -5), ActiveCell.Offset(0, -1)).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Range(ActiveCell.Offset(0, -5), ActiveCell.Offset(0, -1)).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.Bold = True
End With
End Sub
This Code is working but i try Remove highlight row , i try text UNBOLD but not remove high-light Row , pleased solve this queryHi Krunal,
Try this VBA trick, it can be helpful or will give you some idea.
How it works:
If according to your example, you select "E2" & make it bold, to Highlight raw on red color with white font & bold, you should click (or arrow key down) to down (cell E3) or click (or arrow key right) right cells (cell F2)VBA Code:Private Sub Worksheet_SelectionChange(ByVal Target As Range) On Error Resume Next If ActiveCell.Offset(-1).Font.Bold = True Then If ActiveCell.Offset(-1).Column <> 5 Then Exit Sub Call Color_Row_UP End If If ActiveCell.Offset(0, -1).Font.Bold = True Then If ActiveCell.Offset(0, -1).Column <> 5 Then Exit Sub Call Color_Row_Left End If End Sub Sub Color_Row_UP() With Range(ActiveCell.Offset(-1), ActiveCell.Offset(-1, -4)).Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .Color = 255 .TintAndShade = 0 .PatternTintAndShade = 0 End With With Range(ActiveCell.Offset(-1), ActiveCell.Offset(-1, -4)).Font .ThemeColor = xlThemeColorDark1 .TintAndShade = 0 .Bold = True End With End Sub Sub Color_Row_Left() With Range(ActiveCell.Offset(0, -5), ActiveCell.Offset(0, -1)).Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .Color = 255 .TintAndShade = 0 .PatternTintAndShade = 0 End With With Range(ActiveCell.Offset(0, -5), ActiveCell.Offset(0, -1)).Font .ThemeColor = xlThemeColorDark1 .TintAndShade = 0 .Bold = True End With End Sub
do you mean if change back bolded text to non-bold, remove highlight? -Yes that's rightHi Krunal,
Could you please clarify what do you mean
i try Remove highlight row
,
do you mean if change back bolded text to non-bold, remove highlight?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If ActiveCell.Offset(-1).Font.Bold = True Then
If ActiveCell.Offset(-1).Column <> 5 Then Exit Sub
Call Color_Row_UP_Bold
End If
If ActiveCell.Offset(-1).Font.Bold = False Then
If ActiveCell.Offset(-1).Column <> 5 Then Exit Sub
Call Color_Row_UP_Regular
End If
End Sub
Sub Color_Row_UP_Bold()
With Range(ActiveCell.Offset(-1), ActiveCell.Offset(-1, -4)).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Range(ActiveCell.Offset(-1), ActiveCell.Offset(-1, -4)).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.Bold = True
End With
End Sub
Sub Color_Row_UP_Regular()
With Range(ActiveCell.Offset(-1), ActiveCell.Offset(-1, -4)).Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Range(ActiveCell.Offset(-1), ActiveCell.Offset(-1, -4)).Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Bold = False
End With
End Sub
[*]