Changing Cell Color with macro

G

Guest

Hi,

Does anyone know how to change the cell color with macro in Excel 97.
The following code only works in Excel 2000

Sheet13.Cells(1,2).Interior.Color = RGB(126, 255, 126) 'Grey

In Excel 97, it gives the following error:
Unable to set the Color property of the Interior class

Regards,
Chris
 
M

MrScience

Chris said:
Hi,

Does anyone know how to change the cell color with macro in Excel 97.
The following code only works in Excel 2000

Sheet13.Cells(1,2).Interior.Color = RGB(126, 255, 126) 'Grey

In Excel 97, it gives the following error:
Unable to set the Color property of the Interior class

Regards,
Chris

I don't know if this will help, but I usually just use something like
this . . .
With Sheets("Sheet13")
Range("A2").Interior.Color = RGB(126,255,126)
End With
 
B

Bob Phillips

That code works perfectly well in Excel 97.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
D

Dave Peterson

How do you execute this code?

Do you run it from a commandbutton placed on a worksheet (or another control
from the control toolbox toolbar)?

If yes, then maybe it's a bug in xl97 that was fixed in xl2k.

If you use a control that has a .takefocusonclick property, toggle that property
to false.

If you use a control that doesn't have that property, add this near the top of
your code:

activecell.activate
 
G

Guest

Hi,

The code was executed from a command control.
I've placed activecell.activate and now it works fine.
Thank you for your help.

Regards,
Chris
 

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