Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing font color in named range using vba Mike H Excel Programming 0 February 5th 09 12:44 PM
Font color changing by itself EJamison Excel Discussion (Misc queries) 2 September 18th 08 05:34 PM
Changing Font color based on font type or size John Excel Discussion (Misc queries) 2 February 7th 08 12:50 AM
Changing Font Color bagoxc Excel Discussion (Misc queries) 2 July 17th 06 01:14 AM
Changing the font color using VBA magoobee Excel Programming 1 June 4th 05 03:51 PM


All times are GMT +1. The time now is 12:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"