How to change cell colors using a macro

  • Thread starter Thread starter Senseability
  • Start date Start date
S

Senseability

I have created a calendar where,i.e., a cell shown as
light green means once thing, yellow another, etc. But
the user needs to change these constantly as dates
is "rescheduled". So I have created a "Clear" button,
that if they highlight the appropriate cells, the user
can just press the clear button to have the cell default
back to white. This is necessary because some people who
do not know how excel works will be "scheduling". Any
advice?
 
Not sure what you want as you say you have created the button, but let's
assume that you want the code. This clears the activecell

Sub ClearColour_Click()
ActiveCell.Interior.ColorIndex = xlColorIndexNone
End Sub

When you say you have a calendar, are the colours anything to do with the
date (e.g. weekends as opposed to weekdays), or to do with the value in the
cell (e.g. no value is clear, Y is one colour, N another)? If so, you could
use conditional formatting to set the colour automatically.

Post back if we can go further.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
So I have created a "Clear" button,

For info only......white is not the default color. No Color is the default.

If you color your cells white you will lose gridlines at these cells.

Gord Dibben XL2002
 
.... which is why I used xlColorindexNone

Bob

For info only......white is not the default color. No Color is the default.

If you color your cells white you will lose gridlines at these cells.

Gord Dibben XL2002
 
Sorry Bob.

Comment was meant to be directed to OP. I had noticed the xlColorindexNone in
your code and wondered if OP would pick up the nuance.

Gord

... which is why I used xlColorindexNone

Bob

Gord Dibben XL2002
 
Gord,

Yeah, I know what you were saying, and I was just adding my comment to
clarify for the OP. Sometimes trying to be succinct means that I'm too
abrupt, a trait I have picked up from email and NGs.

Best Regards

Bob
 
Back
Top