Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Changing Cell Color with macro

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Changing Cell Color with macro


Chris L wrote:
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Changing Cell Color with macro

That code works perfectly well in Excel 97.

--
HTH

Bob Phillips

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

"Chris L" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Changing Cell Color with macro

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



Chris L wrote:

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


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Changing Cell Color with macro

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

"Dave Peterson" wrote:

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



Chris L wrote:

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


--

Dave Peterson



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 the color of a cell based on the color of another cell. LATC Excel Discussion (Misc queries) 7 December 4th 09 09:49 PM
Changing the Color of Specific Characters using a Macro Frustrated IT Tech Excel Worksheet Functions 6 April 26th 08 05:19 PM
changing the color of a cell zhj23 Excel Discussion (Misc queries) 6 December 1st 07 03:09 AM
Excel Macro: Changing Color of Cell kevinknight09[_2_] Excel Programming 7 August 2nd 06 08:14 PM
Macro for Changing Cell Background Color [email protected] Excel Programming 7 December 2nd 05 05:39 PM


All times are GMT +1. The time now is 07:52 PM.

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"