PC Review


Reply
Thread Tools Rate Thread

Color Cells by macro NOT conditional format

 
 
=?Utf-8?B?RFRUT0RHRw==?=
Guest
Posts: n/a
 
      25th Jul 2007
Hello,

I would like to know if there is a way to color a cell based on it's value,
but not using the conditional format command.

If the date in column B is more than 45 days old, make the background of
font bright pink.

I need lots of specific help because I'm not comfortable with the VB editor
yet.

Thank you!
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      25th Jul 2007
Hi,

Im not at all sure about the pink but everyone to their own, Right click the
sheet tab, view code and paste this in

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("B:B")) Is Nothing Then
today = Now
If Target.Value < today - 45 Then
On Error Resume Next
Application.EnableEvents = False
Target.Font.ColorIndex = 7 ' for font
Target.Interior.ColorIndex = 7
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End Sub

"DTTODGG" wrote:

> Hello,
>
> I would like to know if there is a way to color a cell based on it's value,
> but not using the conditional format command.
>
> If the date in column B is more than 45 days old, make the background of
> font bright pink.
>
> I need lots of specific help because I'm not comfortable with the VB editor
> yet.
>
> Thank you!

 
Reply With Quote
 
=?Utf-8?B?RFRUT0RHRw==?=
Guest
Posts: n/a
 
      25th Jul 2007
Thank you Mike for your oh-so-quick-reply!

I typed everything in as stated. Does something make it "go"? Do I need to
"run" this or "save" that or something?

Sorry for my lack of knowledge, but I'm learning everyday thanks to people
like you.

"Mike H" wrote:

> Hi,
>
> Im not at all sure about the pink but everyone to their own, Right click the
> sheet tab, view code and paste this in
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
> If Not Intersect(Target, Range("B:B")) Is Nothing Then
> today = Now
> If Target.Value < today - 45 Then
> On Error Resume Next
> Application.EnableEvents = False
> Target.Font.ColorIndex = 7 ' for font
> Target.Interior.ColorIndex = 7
> Application.EnableEvents = True
> On Error GoTo 0
> End If
> End If
> End Sub
>
> "DTTODGG" wrote:
>
> > Hello,
> >
> > I would like to know if there is a way to color a cell based on it's value,
> > but not using the conditional format command.
> >
> > If the date in column B is more than 45 days old, make the background of
> > font bright pink.
> >
> > I need lots of specific help because I'm not comfortable with the VB editor
> > yet.
> >
> > Thank you!

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      25th Jul 2007
If you right click the sheet tab that you want to use the macro in, then
click view code, you will open the sheet code window. Copy Mike's code to
that window and save the file. Then when you change the Target cell, it
should apply the color.
"DTTODGG" wrote:

> Thank you Mike for your oh-so-quick-reply!
>
> I typed everything in as stated. Does something make it "go"? Do I need to
> "run" this or "save" that or something?
>
> Sorry for my lack of knowledge, but I'm learning everyday thanks to people
> like you.
>
> "Mike H" wrote:
>
> > Hi,
> >
> > Im not at all sure about the pink but everyone to their own, Right click the
> > sheet tab, view code and paste this in
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
> > If Not Intersect(Target, Range("B:B")) Is Nothing Then
> > today = Now
> > If Target.Value < today - 45 Then
> > On Error Resume Next
> > Application.EnableEvents = False
> > Target.Font.ColorIndex = 7 ' for font
> > Target.Interior.ColorIndex = 7
> > Application.EnableEvents = True
> > On Error GoTo 0
> > End If
> > End If
> > End Sub
> >
> > "DTTODGG" wrote:
> >
> > > Hello,
> > >
> > > I would like to know if there is a way to color a cell based on it's value,
> > > but not using the conditional format command.
> > >
> > > If the date in column B is more than 45 days old, make the background of
> > > font bright pink.
> > >
> > > I need lots of specific help because I'm not comfortable with the VB editor
> > > yet.
> > >
> > > Thank you!

 
Reply With Quote
 
theSquirrel
Guest
Posts: n/a
 
      26th Jul 2007
On Jul 25, 2:22 pm, JLGWhiz <JLGW...@discussions.microsoft.com> wrote:
> If you right click the sheet tab that you want to use the macro in, then
> click view code, you will open the sheet code window. Copy Mike's code to
> that window and save the file. Then when you change the Target cell, it
> should apply the color.
>
> "DTTODGG" wrote:
> > Thank you Mike for your oh-so-quick-reply!

>
> > I typed everything in as stated. Does something make it "go"? Do I need to
> > "run" this or "save" that or something?

>
> > Sorry for my lack of knowledge, but I'm learning everyday thanks to people
> > like you.

>
> > "Mike H" wrote:

>
> > > Hi,

>
> > > Im not at all sure about the pink but everyone to their own, Right click the
> > > sheet tab, view code and paste this in

>
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
> > > If Not Intersect(Target, Range("B:B")) Is Nothing Then
> > > today = Now
> > > If Target.Value < today - 45 Then
> > > On Error Resume Next
> > > Application.EnableEvents = False
> > > Target.Font.ColorIndex = 7 ' for font
> > > Target.Interior.ColorIndex = 7
> > > Application.EnableEvents = True
> > > On Error GoTo 0
> > > End If
> > > End If
> > > End Sub

>
> > > "DTTODGG" wrote:

>
> > > > Hello,

>
> > > > I would like to know if there is a way to color a cell based on it's value,
> > > > but not using the conditional format command.

>
> > > > If the date in column B is more than 45 days old, make the background of
> > > > font bright pink.

>
> > > > I need lots of specific help because I'm not comfortable with the VB editor
> > > > yet.

>
> > > > Thank you!


In my experience, running with the Worksheet_Change sub causes a
relative performance hit to how much code you add there. Be wary when
using it as it can cause frustration to users if the lag is to long
each time they click... even a half second delay is very noticable.

 
Reply With Quote
 
=?Utf-8?B?RFRUT0RHRw==?=
Guest
Posts: n/a
 
      26th Jul 2007
Thank you. Silly me, I thought it would just "update" all the current fields
I have in the column. It only changes when I modify the date. Is there a way
to "refresh" or "update" the current cells? Like "run macro" or something?

Anyway, this solution works wonderfully. I just need to know how to learn
this stuff myself - someday.

Thanks again!

"JLGWhiz" wrote:

> If you right click the sheet tab that you want to use the macro in, then
> click view code, you will open the sheet code window. Copy Mike's code to
> that window and save the file. Then when you change the Target cell, it
> should apply the color.
> "DTTODGG" wrote:
>
> > Thank you Mike for your oh-so-quick-reply!
> >
> > I typed everything in as stated. Does something make it "go"? Do I need to
> > "run" this or "save" that or something?
> >
> > Sorry for my lack of knowledge, but I'm learning everyday thanks to people
> > like you.
> >
> > "Mike H" wrote:
> >
> > > Hi,
> > >
> > > Im not at all sure about the pink but everyone to their own, Right click the
> > > sheet tab, view code and paste this in
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
> > > If Not Intersect(Target, Range("B:B")) Is Nothing Then
> > > today = Now
> > > If Target.Value < today - 45 Then
> > > On Error Resume Next
> > > Application.EnableEvents = False
> > > Target.Font.ColorIndex = 7 ' for font
> > > Target.Interior.ColorIndex = 7
> > > Application.EnableEvents = True
> > > On Error GoTo 0
> > > End If
> > > End If
> > > End Sub
> > >
> > > "DTTODGG" wrote:
> > >
> > > > Hello,
> > > >
> > > > I would like to know if there is a way to color a cell based on it's value,
> > > > but not using the conditional format command.
> > > >
> > > > If the date in column B is more than 45 days old, make the background of
> > > > font bright pink.
> > > >
> > > > I need lots of specific help because I'm not comfortable with the VB editor
> > > > yet.
> > > >
> > > > Thank you!

 
Reply With Quote
 
=?Utf-8?B?RFRUT0RHRw==?=
Guest
Posts: n/a
 
      26th Jul 2007
What are some other options?
For this particular case, I think everything will work out fine, but I'd
like to learn about other options for the future.

"theSquirrel" wrote:

> On Jul 25, 2:22 pm, JLGWhiz <JLGW...@discussions.microsoft.com> wrote:
> > If you right click the sheet tab that you want to use the macro in, then
> > click view code, you will open the sheet code window. Copy Mike's code to
> > that window and save the file. Then when you change the Target cell, it
> > should apply the color.
> >
> > "DTTODGG" wrote:
> > > Thank you Mike for your oh-so-quick-reply!

> >
> > > I typed everything in as stated. Does something make it "go"? Do I need to
> > > "run" this or "save" that or something?

> >
> > > Sorry for my lack of knowledge, but I'm learning everyday thanks to people
> > > like you.

> >
> > > "Mike H" wrote:

> >
> > > > Hi,

> >
> > > > Im not at all sure about the pink but everyone to their own, Right click the
> > > > sheet tab, view code and paste this in

> >
> > > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > > If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
> > > > If Not Intersect(Target, Range("B:B")) Is Nothing Then
> > > > today = Now
> > > > If Target.Value < today - 45 Then
> > > > On Error Resume Next
> > > > Application.EnableEvents = False
> > > > Target.Font.ColorIndex = 7 ' for font
> > > > Target.Interior.ColorIndex = 7
> > > > Application.EnableEvents = True
> > > > On Error GoTo 0
> > > > End If
> > > > End If
> > > > End Sub

> >
> > > > "DTTODGG" wrote:

> >
> > > > > Hello,

> >
> > > > > I would like to know if there is a way to color a cell based on it's value,
> > > > > but not using the conditional format command.

> >
> > > > > If the date in column B is more than 45 days old, make the background of
> > > > > font bright pink.

> >
> > > > > I need lots of specific help because I'm not comfortable with the VB editor
> > > > > yet.

> >
> > > > > Thank you!

>
> In my experience, running with the Worksheet_Change sub causes a
> relative performance hit to how much code you add there. Be wary when
> using it as it can cause frustration to users if the lag is to long
> each time they click... even a half second delay is very noticable.
>
>

 
Reply With Quote
 
=?Utf-8?B?RFRUT0RHRw==?=
Guest
Posts: n/a
 
      26th Jul 2007
Mike,

As far as the Pink goes, I just wanted something different.
Where do I find the values of other colors and fonts?

Thanks again.

"Mike H" wrote:

> Hi,
>
> Im not at all sure about the pink but everyone to their own, Right click the
> sheet tab, view code and paste this in
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
> If Not Intersect(Target, Range("B:B")) Is Nothing Then
> today = Now
> If Target.Value < today - 45 Then
> On Error Resume Next
> Application.EnableEvents = False
> Target.Font.ColorIndex = 7 ' for font
> Target.Interior.ColorIndex = 7
> Application.EnableEvents = True
> On Error GoTo 0
> End If
> End If
> End Sub
>
> "DTTODGG" wrote:
>
> > Hello,
> >
> > I would like to know if there is a way to color a cell based on it's value,
> > but not using the conditional format command.
> >
> > If the date in column B is more than 45 days old, make the background of
> > font bright pink.
> >
> > I need lots of specific help because I'm not comfortable with the VB editor
> > yet.
> >
> > Thank you!

 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      26th Jul 2007
ColorIndex numbers
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)
'--
1 Black
2 White
3 Red
4 Bright Green
5 Blue
6 Yellow
7 Pink
8 Turquoise
9 Dark Red
10 Green
11 Dark Blue
12 Dark Yellow
13 Violet
14 Teal
15 Gray-25%
16 Gray-50%
17 Periwinkle
18 Plum
19 Ivory
20 Light Turquoise
21 Dark Purple
22 Coral
23 Ocean Blue
24 Ice Blue
25 Dark Blue
26 Pink
27 Yellow
28 Turquoise
29 Violet
30 Dark Red
31 Teal
32 Blue
33 Sky Blue
34 Light Turquoise
35 Light Green
36 Light Yellow
37 Pale Blue
38 Rose
39 Lavender
40 Tan
41 Light Blue
42 Aqua
43 Lime
44 Gold
45 Light Orange
46 Orange
47 Blue-Gray
48 Gray-40%
49 Dark Teal
50 Sea Green
51 Dark Green
52 Olive Green
53 Brown
54 Plum
55 Indigo
56 Gray-80%
'-----------------



"DTTODGG"
<(E-Mail Removed)>
wrote in message
Mike,
As far as the Pink goes, I just wanted something different.
Where do I find the values of other colors and fonts?
Thanks again.

 
Reply With Quote
 
=?Utf-8?B?RFRUT0RHRw==?=
Guest
Posts: n/a
 
      26th Jul 2007
Thank you Jim!

"Jim Cone" wrote:

> ColorIndex numbers
> --
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
> (Excel Add-ins / Excel Programming)
> '--
> 1 Black
> 2 White
> 3 Red
> 4 Bright Green
> 5 Blue
> 6 Yellow
> 7 Pink
> 8 Turquoise
> 9 Dark Red
> 10 Green
> 11 Dark Blue
> 12 Dark Yellow
> 13 Violet
> 14 Teal
> 15 Gray-25%
> 16 Gray-50%
> 17 Periwinkle
> 18 Plum
> 19 Ivory
> 20 Light Turquoise
> 21 Dark Purple
> 22 Coral
> 23 Ocean Blue
> 24 Ice Blue
> 25 Dark Blue
> 26 Pink
> 27 Yellow
> 28 Turquoise
> 29 Violet
> 30 Dark Red
> 31 Teal
> 32 Blue
> 33 Sky Blue
> 34 Light Turquoise
> 35 Light Green
> 36 Light Yellow
> 37 Pale Blue
> 38 Rose
> 39 Lavender
> 40 Tan
> 41 Light Blue
> 42 Aqua
> 43 Lime
> 44 Gold
> 45 Light Orange
> 46 Orange
> 47 Blue-Gray
> 48 Gray-40%
> 49 Dark Teal
> 50 Sea Green
> 51 Dark Green
> 52 Olive Green
> 53 Brown
> 54 Plum
> 55 Indigo
> 56 Gray-80%
> '-----------------
>
>
>
> "DTTODGG"
> <(E-Mail Removed)>
> wrote in message
> Mike,
> As far as the Pink goes, I just wanted something different.
> Where do I find the values of other colors and fonts?
> Thanks again.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Format, Color Scale adjacent cells Michael_R Microsoft Excel Misc 3 4th Feb 2010 10:40 PM
Excel 2003 Conditional Format Color Cells Issue in SharePoint 3.0 G_man Microsoft Excel Misc 0 21st May 2009 05:09 PM
Excel 2003 Conditional Format Color Cells Issue in SharePoint 3.0 G_man Microsoft Excel Misc 0 21st May 2009 05:09 PM
Recognition of color pattern in cells to use in Conditional format =?Utf-8?B?UXVhbmRhcnkgICAgMTEgLSAzIC0gMDc=?= Microsoft Excel Misc 1 17th May 2007 08:07 AM
Conditional Format Macro fails to set interior color - HELP!!! bttman Microsoft Excel Programming 0 1st Apr 2006 02:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:08 PM.