VBA Code for Font Color =

Justinian

Well-known Member
Joined
Aug 9, 2009
Messages
1,557
Office Version
  1. 365
Platform
  1. Windows
I have some basic code below to automatically highlight a row a predetermined cell color after a double click. How do I modify this code to also change the font to bold white?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
If Target.Interior.ColorIndex = xlNone Then
Target.EntireRow.Interior.ColorIndex = 15
Else
Target.EntireRow.Interior.ColorIndex = xlNone
End If
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
start recording a macro,
select row and turn it bold & white
stop recording macro
edit macro,
take that code and put it in with your code.
(you may have to alter the target row to : selection.entirerow
or Activecell.interior…)
 
Upvote 0
I already tried that and it did not work because this code above was written whereas the macro recorded code is different (see example):

Range("C18").Select
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
 
Upvote 0
Try....
VBA Code:
    If Target.Interior.ColorIndex = xlNone Then
        With Target.EntireRow
            .Interior.ColorIndex = 15
            .Font.ColorIndex = 2
            .Font.Bold = True
        End With
    Else
        Target.EntireRow.Interior.ColorIndex = xlNone
 
Last edited:
Upvote 0
That works but I cannot double click again to remove the highlighting (as I could previously).
 
Upvote 0
Sorry, there was a typo in the code, see the edited code in the previous post
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,874
Members
449,056
Latest member
ruhulaminappu

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