PC Review


Reply
Thread Tools Rate Thread

Colour macro

 
 
LITTLE PETE
Guest
Posts: n/a
 
      18th Jun 2008
Afternoon

I have my data that I want to review in column H and depending on the data
in that coloumn colour the entire row (columns A to J).

An example of a code is;
ZL049 which I want to be Yellow
EZ006 which I want to be Green
EY001 which I want to be purple

How do I write and where?

Many thanks
Pete

 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      18th Jun 2008
Without code (that is without VBA) use Condiitonal formatting with Formula Is.

Using code:

Sub LittlePete()
v1 = "ZL049"
v2 = "EZ006"
v3 = "EY001"
n = Cells(Rows.Count, "J").End(xlUp).Row
Set rr = Range("J1:J" & n)
yellow = 6
green = 10
purple = 13
For Each r In rr
v = r.Value
If v = v1 Then r.EntireRow.Interior.ColorIndex = yellow
If v = v2 Then r.EntireRow.Interior.ColorIndex = green
If v = v3 Then r.EntireRow.Interior.ColorIndex = purple
Next
End Sub
--
Gary''s Student - gsnu200793


"LITTLE PETE" wrote:

> Afternoon
>
> I have my data that I want to review in column H and depending on the data
> in that coloumn colour the entire row (columns A to J).
>
> An example of a code is;
> ZL049 which I want to be Yellow
> EZ006 which I want to be Green
> EY001 which I want to be purple
>
> How do I write and where?
>
> Many thanks
> Pete
>

 
Reply With Quote
 
LITTLE PETE
Guest
Posts: n/a
 
      18th Jun 2008
Thanks Gary

If the code changes from being alpha/numeric (ZL049) to just numeric like
"19" will anything need to change? I have looked at the data and using just
numbers will be a lot easier and faster.

Also were is it best to keep this, on the sheet or as a module?
Thanks Peter



"Gary''s Student" wrote:

> Without code (that is without VBA) use Condiitonal formatting with Formula Is.
>
> Using code:
>
> Sub LittlePete()
> v1 = "ZL049"
> v2 = "EZ006"
> v3 = "EY001"
> n = Cells(Rows.Count, "J").End(xlUp).Row
> Set rr = Range("J1:J" & n)
> yellow = 6
> green = 10
> purple = 13
> For Each r In rr
> v = r.Value
> If v = v1 Then r.EntireRow.Interior.ColorIndex = yellow
> If v = v2 Then r.EntireRow.Interior.ColorIndex = green
> If v = v3 Then r.EntireRow.Interior.ColorIndex = purple
> Next
> End Sub
> --
> Gary''s Student - gsnu200793
>
>
> "LITTLE PETE" wrote:
>
> > Afternoon
> >
> > I have my data that I want to review in column H and depending on the data
> > in that coloumn colour the entire row (columns A to J).
> >
> > An example of a code is;
> > ZL049 which I want to be Yellow
> > EZ006 which I want to be Green
> > EY001 which I want to be purple
> >
> > How do I write and where?
> >
> > Many thanks
> > Pete
> >

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      19th Jun 2008
I like to keep macros in a module.

Changing from alpha to numeric is something like:

v1=19
--
Gary''s Student - gsnu200793


"LITTLE PETE" wrote:

> Thanks Gary
>
> If the code changes from being alpha/numeric (ZL049) to just numeric like
> "19" will anything need to change? I have looked at the data and using just
> numbers will be a lot easier and faster.
>
> Also were is it best to keep this, on the sheet or as a module?
> Thanks Peter
>
>
>
> "Gary''s Student" wrote:
>
> > Without code (that is without VBA) use Condiitonal formatting with Formula Is.
> >
> > Using code:
> >
> > Sub LittlePete()
> > v1 = "ZL049"
> > v2 = "EZ006"
> > v3 = "EY001"
> > n = Cells(Rows.Count, "J").End(xlUp).Row
> > Set rr = Range("J1:J" & n)
> > yellow = 6
> > green = 10
> > purple = 13
> > For Each r In rr
> > v = r.Value
> > If v = v1 Then r.EntireRow.Interior.ColorIndex = yellow
> > If v = v2 Then r.EntireRow.Interior.ColorIndex = green
> > If v = v3 Then r.EntireRow.Interior.ColorIndex = purple
> > Next
> > End Sub
> > --
> > Gary''s Student - gsnu200793
> >
> >
> > "LITTLE PETE" wrote:
> >
> > > Afternoon
> > >
> > > I have my data that I want to review in column H and depending on the data
> > > in that coloumn colour the entire row (columns A to J).
> > >
> > > An example of a code is;
> > > ZL049 which I want to be Yellow
> > > EZ006 which I want to be Green
> > > EY001 which I want to be purple
> > >
> > > How do I write and where?
> > >
> > > Many thanks
> > > Pete
> > >

 
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
macro for Tab colour change Mike Microsoft Excel Misc 3 17th Dec 2009 12:45 AM
colour macro =?Utf-8?B?QWZpYQ==?= Microsoft Excel Programming 3 27th Apr 2007 01:00 PM
Font Colour Macro =?Utf-8?B?U3VraA==?= Microsoft Excel Programming 1 19th Sep 2006 09:39 AM
RE: Colour search macro =?Utf-8?B?SyBEYWxlcw==?= Microsoft Excel Programming 0 8th Nov 2004 05:39 PM
Colour Macro Ntisch Microsoft Excel Programming 2 10th Feb 2004 10:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:28 PM.