Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Code to change the color of "Rectangle21_Click"


-----Original Message-----
Why not skip the rectangle and use the Change event or the

calculate event
to change the background color of a cell since you are

exceeding the
capabilities of conditional formatting.

You can unprotect the sheet in your code and change the

background color,
then reprotect the sheet. Alternatively you can use the

UserInterActiveOnly
property of the protect method to allow you macro to work

on a protected
sheet.

Private Sub Worksheet_Change(ByVal Target As Range)
me.Protect UserInterfaceOnly:=True
if Target.Address = "$B$9" then
select Case Target.Value
case 1
target.Interior.colorIndex = 3
case 2
target.interior.colorIndex = 4
End Select
End if
End Sub

Obviously, the case statement would need to be adjusted to

accomplish the
functionality you want. In xl2003 and perhaps xl2002 you

need to supply
the password with the protect command (if the sheet has one).
--
Regards,
Tom Ogilvy


"Ed" wrote in message
...
I need the option to change the background color of a cell
to as many as 5 different colors and still be able to
protect the cell. I can accomplish 4 different colors with
"Conditional Formatting".
I could use a "Rectangle" to cover the cell, and then
switch the color of the rectangle from a color to
transparent to get the fifth color.
Is there Code that will change the color of a "Rectangle"?
Such as: Worksheets("abc").?????????
Or is that impossible?
Thankyou,
Ed



.
Hi Tom

I used the following code at the beginning of the Macro:
Worksheets("abc").Unprotect
And this at the end:
Worksheets("abc").Protect

It works fine except for one thing.

If you protect the sheet with a password, you have to enter
the password in order to run the Macro.
You would have to give the password to who ever was going
to run the Macro. Making it impossible to protect the sheet.
Do you know of a remidy for this?
Thankyou
Ed


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
How to change custom color's tooltips from "Color Scheme"? Andy Smith[_2_] Excel Discussion (Misc queries) 0 June 10th 08 07:27 PM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
How to change text color in a cell "comment" in Office 2007? conductor Excel Worksheet Functions 1 June 2nd 07 02:50 AM
VBA code to "background-color" a cell obtaining a value from Row EagleOne Excel Discussion (Misc queries) 1 August 2nd 06 05:57 PM
How do I color code the "SHEET1" Tab in Excel? kmtg Excel Worksheet Functions 3 June 14th 06 04:13 PM


All times are GMT +1. The time now is 06:50 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"