Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 6
Default Row color by grouping?

I have some product codes in 3 columns that are sorted. I would like to alternate the color of rows
when a product code changes. How done?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Row color by grouping?

Additional column, assume A.
Assume your data is now in Col B and is sorted on Col B such that changes in
Col B denote required change of colour.
In A2 =--(B2<B1)
In A3 =(B3<B2)+A2 and copy down as far as your data goes

Select the entire sheet, do Format / Conditional Formatting, change cell
value is to Formula is and put in

=MOD($A1,2)=0

Choose a colour from the pattern tab on the format dialog box and hit OK

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"guy" wrote in message
...
I have some product codes in 3 columns that are sorted. I would like to

alternate the color of rows
when a product code changes. How done?



  #3   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 6
Default Row color by grouping?

On Fri, 4 Feb 2005 00:49:58 -0000, "Ken Wright" wrote:

Additional column, assume A.
Assume your data is now in Col B and is sorted on Col B such that changes in
Col B denote required change of colour.
In A2 =--(B2<B1)
In A3 =(B3<B2)+A2 and copy down as far as your data goes

Select the entire sheet, do Format / Conditional Formatting, change cell
value is to Formula is and put in

=MOD($A1,2)=0

Choose a colour from the pattern tab on the format dialog box and hit OK


What if my data is in Col B, Col C and Col D? Changes in either of these denote required change of
colour.

Thank you for your time.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Row color by grouping?

A2 =--(B2&C2&D2<B1&C1&D1)
A3 =(B3&C3&D3<B2&C2&D2)+A2 and copy down

Hide Col A and you won't even know it's there

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"guy" wrote in message
...
On Fri, 4 Feb 2005 00:49:58 -0000, "Ken Wright"

wrote:

Additional column, assume A.
Assume your data is now in Col B and is sorted on Col B such that changes

in
Col B denote required change of colour.
In A2 =--(B2<B1)
In A3 =(B3<B2)+A2 and copy down as far as your data goes

Select the entire sheet, do Format / Conditional Formatting, change cell
value is to Formula is and put in

=MOD($A1,2)=0

Choose a colour from the pattern tab on the format dialog box and hit OK


What if my data is in Col B, Col C and Col D? Changes in either of these

denote required change of
colour.

Thank you for your time.



  #5   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 6
Default Row color by grouping?

On Fri, 4 Feb 2005 01:14:14 -0000, "Ken Wright" wrote:

A2 =--(B2&C2&D2<B1&C1&D1)
A3 =(B3&C3&D3<B2&C2&D2)+A2 and copy down

Hide Col A and you won't even know it's there


Good stuff.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Row color by grouping?

That is a unique solution that I just had not thought of... Very interesting.
I knew that I hung out in this forum for a reason...

"Ken Wright" wrote:

Additional column, assume A.
Assume your data is now in Col B and is sorted on Col B such that changes in
Col B denote required change of colour.
In A2 =--(B2<B1)
In A3 =(B3<B2)+A2 and copy down as far as your data goes

Select the entire sheet, do Format / Conditional Formatting, change cell
value is to Formula is and put in

=MOD($A1,2)=0

Choose a colour from the pattern tab on the format dialog box and hit OK

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"guy" wrote in message
...
I have some product codes in 3 columns that are sorted. I would like to

alternate the color of rows
when a product code changes. How done?




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Row color by grouping?

:-) My last post covers the three columns instead of just one

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------

"Jim Thomlinson" wrote in message
...
That is a unique solution that I just had not thought of... Very

interesting.
I knew that I hung out in this forum for a reason...

"Ken Wright" wrote:

Additional column, assume A.
Assume your data is now in Col B and is sorted on Col B such that

changes in
Col B denote required change of colour.
In A2 =--(B2<B1)
In A3 =(B3<B2)+A2 and copy down as far as your data goes

Select the entire sheet, do Format / Conditional Formatting, change cell
value is to Formula is and put in

=MOD($A1,2)=0

Choose a colour from the pattern tab on the format dialog box and hit OK

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03


--------------------------------------------------------------------------

--
It's easier to beg forgiveness than ask permission :-)


--------------------------------------------------------------------------

--

"guy" wrote in message
...
I have some product codes in 3 columns that are sorted. I would like

to
alternate the color of rows
when a product code changes. How done?






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Row color by grouping?

Here's a variation on the same theme. In A1 put the number 1. In A2
=IF(B2<B1,1-A1,A1). For the CF condition, use 0 or 1 and set the format for
those rows.



On Thu, 3 Feb 2005 17:15:01 -0800, "Jim Thomlinson"
wrote:

That is a unique solution that I just had not thought of... Very interesting.
I knew that I hung out in this forum for a reason...

"Ken Wright" wrote:

Additional column, assume A.
Assume your data is now in Col B and is sorted on Col B such that changes

in
Col B denote required change of colour.
In A2 =--(B2<B1)
In A3 =(B3<B2)+A2 and copy down as far as your data goes

Select the entire sheet, do Format / Conditional Formatting, change cell
value is to Formula is and put in

=MOD($A1,2)=0

Choose a colour from the pattern tab on the format dialog box and hit OK

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03


----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)

----------------------------------------------------------------------------

"guy" wrote in message
...
I have some product codes in 3 columns that are sorted. I would like to

alternate the color of rows
when a product code changes. How done?





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Row color by grouping?

Here it is in code if you are using conditional formats already for a
different purpose. You will probably want to cahnge the colours which just
requires changing intCoulour1 and intColour2. These should really be
constants anyway...

Sub test()
Dim rngToColour As Range
Dim varLastValue As Variant
Dim intColour1 As Integer
Dim intColour2 As Integer
Dim intCurrentColour As Integer

intColour1 = 2
intColour2 = 3

intCurrentColour = intColour1

Set rngToColour = Sheet1.Range("A2:C2")
varLastValue = rngToColour.Value(1, 1)
Do While rngToColour.Value(1, 1) < ""
rngToColour.Interior.ColorIndex = intCurrentColour
If rngToColour.Value(1, 1) < varLastValue Then
If intCurrentColour = intColour1 Then
intCurrentColour = intColour2
Else
intCurrentColour = intColour1
End If
varLastValue = rngToColour.Value(1, 1)
End If
Set rngToColour = rngToColour.Offset(1, 0)
Loop
End Sub

HTH

"guy" wrote:

I have some product codes in 3 columns that are sorted. I would like to alternate the color of rows
when a product code changes. How done?

  #10   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 6
Default Row color by grouping?

On Thu, 3 Feb 2005 17:11:03 -0800, "Jim Thomlinson" wrote:

Here it is in code if you are using conditional formats already for a
different purpose. You will probably want to cahnge the colours which just
requires changing intCoulour1 and intColour2. These should really be
constants anyway...

Sub test()
Dim rngToColour As Range
Dim varLastValue As Variant
Dim intColour1 As Integer
Dim intColour2 As Integer
Dim intCurrentColour As Integer

intColour1 = 2
intColour2 = 3

intCurrentColour = intColour1

Set rngToColour = Sheet1.Range("A2:C2")
varLastValue = rngToColour.Value(1, 1)
Do While rngToColour.Value(1, 1) < ""
rngToColour.Interior.ColorIndex = intCurrentColour
If rngToColour.Value(1, 1) < varLastValue Then
If intCurrentColour = intColour1 Then
intCurrentColour = intColour2
Else
intCurrentColour = intColour1
End If
varLastValue = rngToColour.Value(1, 1)
End If
Set rngToColour = rngToColour.Offset(1, 0)
Loop
End Sub

HTH


Good stuff. If I am reading this correctly then I would probably set colorindex after determining
intCurrentColour.


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
Powerpoint / Excel: custom pp RGB color doesn't match identical Excelcustom RGB color mikewillnot Charts and Charting in Excel 1 February 26th 08 05:22 PM
Can't format cell color/text color in Office Excel 2003 in fil Tony S Excel Discussion (Misc queries) 1 December 21st 07 01:41 PM
Can't format cell color/text color in Office Excel 2003 in files . albertaman Excel Discussion (Misc queries) 0 February 16th 06 03:56 AM
Excel 2003 will not display color fonts or color fill cells DaveC Excel Worksheet Functions 1 April 11th 05 04:38 PM
Browse Forms Controls and change TextBox color based on cell color StefanW Excel Programming 2 November 21st 04 07:06 PM


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