krunal123

Board Regular
Joined
Jun 26, 2020
Messages
177
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
1647663655810.png


How to Highlight RAW After Bold Text ???
"E2" cell text is bold after Highlight raw on red color with white font & bold also
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi 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
 
Upvote 0
Hi 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
This Code is working but i try Remove highlight row , i try text UNBOLD but not remove high-light Row , pleased solve this query
 
Upvote 0
Hi 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?
 
Upvote 0
Hi 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?
do you mean if change back bolded text to non-bold, remove highlight? -Yes that's right
 
Upvote 0
Hi Krunal,
Below code will highlight or remove the highlighting, depending on the font of the value in column "E"
How it works, example:
  • if you make the "E4" value "Bold" and select (no matter mouse click or down arrow) "E5", it will highlight & make bold all fields in row 4 (range("A4:E4"))
  • if you make the "E4" value "Not Bold" and select (no matter mouse click or down arrow) "E5", it will remove highlighting & make Not Bold all fields in row 4 (range("A4:E4"))
    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_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
    
    
    [*]
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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