Macro to set fill color dark blue and font color white

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,603
Office Version
  1. 2021
Platform
  1. Windows
I have tried to write code to set the fill color in N5:O5 to dark blue and the font color to white

When running the macro I get a run time error, "object does not support this property or method"

It would be appreciated if someone could correct my code




Code:
Sub FillColor ()
with Sheets ("Sales Data")
 .Range("N5:O5").Font.ThemeColor = xlThemeColorDark1
    .TintAndShade = 0
end With
End Sub






I
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try it this way...
VBA Code:
Sub FillColor()
  With Range("N5:O5")
    .Interior.ColorIndex = 25
    .Font.Color = vbWhite
    .Font.Bold = True
  End With
End Sub
Note: I also made the font bold as I find it more readable that way. If you don't want that, just remove the last line of code inside the With..EndWith block.
 
Upvote 0
Thanks for the help Rick. Setting the font to be bold is ideal
 
Upvote 0

Forum statistics

Threads
1,225,188
Messages
6,183,430
Members
453,160
Latest member
DaveM_26

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