unable to set the colorindex property of the font class

S

steve

re the code below, the code will only execute if called
from a form when the spreadsheet is loading. If I call the
code from a button on the sheet itself I obtain an error -

"unable to set the colorindex property of the font class"

I would love an explanation of the problems with the code

Steve

Sub Reveal_Cells(Rng As Range, Default_Value As Variant)
Rng.Interior.ColorIndex = 19
Rng.Font.ColorIndex = 5
Rng.Value = Default_Value
End Sub
 
P

Patrick Molloy

works fine for me. Are you passing a range & value? Is
the cell/sheet protected?

Patrick Molloy
Microsoft Excel MVP
 
S

Steve

Yes I pass in a range + value. The worksheet is not
protected. What is odd is that the line

Rng.Value = Default_Value

Will work fine if the others are commented out, all the
others to do with colors etc cause exceptions if run at
any time other than startup.

I should mention I am using excel 97

thanks

Steve
 
P

Patrick Molloy

is the procedure on a userform's code?
make sure the form is loaded by the button

Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top