Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA Error setting Font.ColorIndex

I've got this very simplistic idea that, when a user changes the text in a
cell, I want to change the colour of the text so they can keep track of what
has been changed and what hasn't. This all seemed very simple, and I ended
up with code like this:

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Font.ColorIndex = 3
End Sub

Very simple indeed. However, it doesn't work. When I come to set the
ColorIndex, the macro fails with an error 1004, "Unable to set the
ColorIndex property of the Font class"

Having failed at that, I tried changing other properties, such as the Color
and Bold properties. All of these failed with the same error. Irritating
thing is, the help file shows an example of setting the ColorIndex of a Font
object, so it must be possible to do.

Anyone know why this wouldn't work?

Thanks
Steve

Office 2003/Excel 2003, Windows/XP SP2 (pro and home)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default VBA Error setting Font.ColorIndex

Works fine here. You have stored it in the worksheet module haven't you.

--
HTH

Bob Phillips

"Steve Barnett" wrote in message
...
I've got this very simplistic idea that, when a user changes the text in a
cell, I want to change the colour of the text so they can keep track of

what
has been changed and what hasn't. This all seemed very simple, and I ended
up with code like this:

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Font.ColorIndex = 3
End Sub

Very simple indeed. However, it doesn't work. When I come to set the
ColorIndex, the macro fails with an error 1004, "Unable to set the
ColorIndex property of the Font class"

Having failed at that, I tried changing other properties, such as the

Color
and Bold properties. All of these failed with the same error. Irritating
thing is, the help file shows an example of setting the ColorIndex of a

Font
object, so it must be possible to do.

Anyone know why this wouldn't work?

Thanks
Steve

Office 2003/Excel 2003, Windows/XP SP2 (pro and home)




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA Error setting Font.ColorIndex

Yes.

Had another play - and realised that the sheet I was modifying was protected
(It's not my spreadsheet - I'm doing someone a favour - will I never learn!)

I modified the code to unprotect the sheet, change the property and
re-protect it and everything is now working fine.

Thanks
Steve


"Bob Phillips" wrote in message
...
Works fine here. You have stored it in the worksheet module haven't you.

--
HTH

Bob Phillips

"Steve Barnett" wrote in message
...
I've got this very simplistic idea that, when a user changes the text in
a
cell, I want to change the colour of the text so they can keep track of

what
has been changed and what hasn't. This all seemed very simple, and I
ended
up with code like this:

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Font.ColorIndex = 3
End Sub

Very simple indeed. However, it doesn't work. When I come to set the
ColorIndex, the macro fails with an error 1004, "Unable to set the
ColorIndex property of the Font class"

Having failed at that, I tried changing other properties, such as the

Color
and Bold properties. All of these failed with the same error. Irritating
thing is, the help file shows an example of setting the ColorIndex of a

Font
object, so it must be possible to do.

Anyone know why this wouldn't work?

Thanks
Steve

Office 2003/Excel 2003, Windows/XP SP2 (pro and home)






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 233
Default VBA Error setting Font.ColorIndex

Maybe it is a protected sheet?

DM Unseen

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default VBA Error setting Font.ColorIndex

That's odd. I thought of that and tried with a protected sheet, but got
nowhere near that error!

--
HTH

Bob Phillips

"Steve Barnett" wrote in message
...
Yes.

Had another play - and realised that the sheet I was modifying was

protected
(It's not my spreadsheet - I'm doing someone a favour - will I never

learn!)

I modified the code to unprotect the sheet, change the property and
re-protect it and everything is now working fine.

Thanks
Steve


"Bob Phillips" wrote in message
...
Works fine here. You have stored it in the worksheet module haven't you.

--
HTH

Bob Phillips

"Steve Barnett" wrote in message
...
I've got this very simplistic idea that, when a user changes the text

in
a
cell, I want to change the colour of the text so they can keep track of

what
has been changed and what hasn't. This all seemed very simple, and I
ended
up with code like this:

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Font.ColorIndex = 3
End Sub

Very simple indeed. However, it doesn't work. When I come to set the
ColorIndex, the macro fails with an error 1004, "Unable to set the
ColorIndex property of the Font class"

Having failed at that, I tried changing other properties, such as the

Color
and Bold properties. All of these failed with the same error.

Irritating
thing is, the help file shows an example of setting the ColorIndex of a

Font
object, so it must be possible to do.

Anyone know why this wouldn't work?

Thanks
Steve

Office 2003/Excel 2003, Windows/XP SP2 (pro and home)








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
If Font.ColorIndex = 5 then . . . jeremy nickels Excel Programming 2 March 4th 05 11:29 AM
VBA syntax for Font & Interior ColorIndex Dennis Excel Discussion (Misc queries) 1 November 25th 04 07:38 PM
EXCEL VB Macro Run Time Error 1004 - Setting ColorIndex Erwin[_2_] Excel Programming 4 April 14th 04 03:52 PM
unable to set the colorindex property of the font class steve Excel Programming 3 December 17th 03 02:41 PM
Font and Fill ColorIndex Frank[_19_] Excel Programming 3 October 31st 03 01:52 PM


All times are GMT +1. The time now is 08:46 AM.

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

About Us

"It's about Microsoft Excel"