#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Colour macro

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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Colour macro

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Colour macro

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Colour macro

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
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
VB Macro for cell colour default KCG Excel Discussion (Misc queries) 2 August 28th 07 12:53 PM
Change Tab colour using Macro Rajat Excel Worksheet Functions 4 October 24th 06 02:31 PM
Setting character colour in a macro JC Excel Discussion (Misc queries) 7 February 23rd 05 09:20 AM
Macro button colour change??? Beefyme Excel Worksheet Functions 1 November 19th 04 06:15 PM
Macro to sort by cell colour CoZ Excel Worksheet Functions 1 November 16th 04 05:52 PM


All times are GMT +1. The time now is 07:13 AM.

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"