![]() |
changing font color in named range using vba
I recieve a runtime error..." method 'color' of object 'font' failed "
this is the code: Private Sub Worksheet_Change(ByVal Target As Range) Dim black As Long Dim white As Long black = vbBlack white = vbWhite If Cells(5, 2).Text = "gable" Then Range("saltboxroofing").Font.Color = white Else If Cells(5, 2).Text = "saltbox" Then Range("saltboxroofing").Font.Color = black Else End If End If End Sub any help is appreciated |
changing font color in named range using vba
thank you for the help. I must have some other underlying problem. it still
kicked the same error but referencing 'colorindex'. "Mike H" wrote: Try this Private Sub Worksheet_Change(ByVal Target As Range) If Cells(5, 2).Text = "gable" Then Range("saltboxroofing").Font.ColorIndex = 2 Else If Cells(5, 2).Text = "saltbox" Then Range("saltboxroofing").Font.ColorIndex = 1 Else End If End If End Sub Mike |
changing font color in named range using vba
Hi,
Check the spelling of your named ranges Mike "punking315" wrote: thank you for the help. I must have some other underlying problem. it still kicked the same error but referencing 'colorindex'. "Mike H" wrote: Try this Private Sub Worksheet_Change(ByVal Target As Range) If Cells(5, 2).Text = "gable" Then Range("saltboxroofing").Font.ColorIndex = 2 Else If Cells(5, 2).Text = "saltbox" Then Range("saltboxroofing").Font.ColorIndex = 1 Else End If End If End Sub Mike |
changing font color in named range using vba
Although I would have written it very differently, I tested in xl2003 sheet
module and it worked, as written. -- Don Guillett Microsoft MVP Excel SalesAid Software "punking315" wrote in message ... I recieve a runtime error..." method 'color' of object 'font' failed " this is the code: Private Sub Worksheet_Change(ByVal Target As Range) Dim black As Long Dim white As Long black = vbBlack white = vbWhite If Cells(5, 2).Text = "gable" Then Range("saltboxroofing").Font.Color = white Else If Cells(5, 2).Text = "saltbox" Then Range("saltboxroofing").Font.Color = black Else End If End If End Sub any help is appreciated |
All times are GMT +1. The time now is 05:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com