Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
sai sai is offline
external usenet poster
 
Posts: 10
Default Shading rows of with similar data

I have a spreadsheet with multiple rows. I have multiple rows for a
given ID which is shown in Column A. I want to group the rows with the
same ID visually by using color bands. The bands should also
alternate.

For e.g. if my data (in column A) looks like the following

A
A
A
B
B
C
C
C
C

I want three rows with A to be shaded in grey. Two rows of B to be
white and 4 rows of C to again in Grey. The number of rows may vary by
the data that is loaded.
Is there a way I can use conditional formatting to do this?

Thanks,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Shading rows of with similar data

Hi
- select your range (e.g. A1:X20)
- in the conditional format dialog enter the following formula:
=MOD(SUMPRODUCT(($A$1:$A1<"")/(COUNTIF($A$1:$A1;$A$1:$A1)+($A$1:$A$1=""))),2)
-choose your color

Assumptions:
- all identical IDs are gouped together

--
Regards
Frank Kabel
Frankfurt, Germany

sai wrote:
I have a spreadsheet with multiple rows. I have multiple rows for a
given ID which is shown in Column A. I want to group the rows with
the same ID visually by using color bands. The bands should also
alternate.

For e.g. if my data (in column A) looks like the following

A
A
A
B
B
C
C
C
C

I want three rows with A to be shaded in grey. Two rows of B to be
white and 4 rows of C to again in Grey. The number of rows may vary
by the data that is loaded.
Is there a way I can use conditional formatting to do this?

Thanks,



  #3   Report Post  
Posted to microsoft.public.excel.programming
sai sai is offline
external usenet poster
 
Posts: 10
Default Shading rows of with similar data

Frank,

Thank you so much. Works !!!

Sai

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Shading rows of with similar data


sai wrote:
Frank,

Thank you so much. Works !!!

Sai


I had to modify the function by adding a ROUND function in order for it
work properly. Excel was not calculating an exact FALSE (i.e., zero)
value in some cases:

=ROUND(MOD(SUMPRODUCT(($A$1:$A1<"")/(COUNTIF($A$1:$A1,$A$1:$A1)+($A$1:$A$1=""))),2),0)

Still, it's an elegant solution I wouldn't have thought of.
Glenn Ray
MOS Master

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
Minimizing Rows of with similar data urlocaljeweler New Users to Excel 3 December 9th 09 06:22 PM
shading data in rows Jamie Excel Discussion (Misc queries) 2 February 7th 08 06:46 PM
Combining rows with similar data robertlewis Excel Discussion (Misc queries) 4 January 27th 07 06:19 PM
Conditional formatting similar to shading alternating rows Conan Kelly Excel Worksheet Functions 10 August 22nd 06 11:13 PM
How do I compare similar rows of data in same worksheet JT Excel Worksheet Functions 2 February 20th 05 06:11 PM


All times are GMT +1. The time now is 01:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"