Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Row Grouping

I need a code that will scan through a sheet and color code rows based
on the first column. So basically all dates that are the same will be
one color. (Oct 25-red,Oct 26-blue...etc..etc)

I've tried doing this with a loop that matches cell Ax with Ax+1 and
for all those that match use a colorindex = y which increases. It does
work but it takes soooo long. I just need something that will read
column 1 and for all the same dates color those rows colorindex y, then
move to the next set of dates. I will have quite a few different dates
which is why i want to use colorindex as it can just increase as the
dates increase.

Thanks for you help!

Justin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Row Grouping

i use this in conditional formatting, i have dates starting in cell a3
=MOD(DAY(A3),2)=1

and

=MOD(MONTH(A3),2)=0

just set the formatting you want for each and apply it to the appropriate cells

--


Gary


"Justin Philips" wrote in message
oups.com...
I need a code that will scan through a sheet and color code rows based
on the first column. So basically all dates that are the same will be
one color. (Oct 25-red,Oct 26-blue...etc..etc)

I've tried doing this with a loop that matches cell Ax with Ax+1 and
for all those that match use a colorindex = y which increases. It does
work but it takes soooo long. I just need something that will read
column 1 and for all the same dates color those rows colorindex y, then
move to the next set of dates. I will have quite a few different dates
which is why i want to use colorindex as it can just increase as the
dates increase.

Thanks for you help!

Justin



  #3   Report Post  
Posted to microsoft.public.excel.programming
DS DS is offline
external usenet poster
 
Posts: 117
Default Row Grouping

I've found the easiest loop to use in something like this would be something
along the lines of:

Sub Baseline()

Dim Baseline As Date
Baseline = "01/10/2005"

Range("B4").Select
Do
Do Until Selection = ""
SelCol = Selection - Baseline
With Selection.Interior
.ColorIndex = SelCol
.Pattern = xlSolid
End With
Selection.Offset(1, 0).Select
Exit Do
Loop
Loop Until Selection = ""

End Sub

This assumes the column with the dates you're looking at is "B" and uses
01/10/05 as the "start" date. Note that using colorindex like this will give
you some really awful colors that may make life tricky for you (e.g.
colorindex 1 is black.... which'll make reading it a little awkward!). This
will look at each line individually though, but is quicker than the method
you describe below.

Hope it helps
DS

"Justin Philips" wrote:

I need a code that will scan through a sheet and color code rows based
on the first column. So basically all dates that are the same will be
one color. (Oct 25-red,Oct 26-blue...etc..etc)

I've tried doing this with a loop that matches cell Ax with Ax+1 and
for all those that match use a colorindex = y which increases. It does
work but it takes soooo long. I just need something that will read
column 1 and for all the same dates color those rows colorindex y, then
move to the next set of dates. I will have quite a few different dates
which is why i want to use colorindex as it can just increase as the
dates increase.

Thanks for you help!

Justin


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Row Grouping

Hey DS,

Thanks! I added a Dim SelCol as single and .ColorIndex = SelCol
+20....this starts the loop at a better color.

What I still need though is to color the entire row....i tired
Range("A2").EntireRow.Selection....but that threw and error.

Any ideas?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Row Grouping

For example,

Rows(2).Interior.ColorIndex = 3

"Justin Philips" wrote:

Hey DS,

Thanks! I added a Dim SelCol as single and .ColorIndex = SelCol
+20....this starts the loop at a better color.

What I still need though is to color the entire row....i tired
Range("A2").EntireRow.Selection....but that threw and error.

Any ideas?


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
Grouping Adrian Excel Worksheet Functions 2 April 2nd 08 01:41 PM
grouping help!!!!!!! perrewperrew Excel Worksheet Functions 1 October 20th 07 04:16 AM
Grouping by day J.Alex. Charts and Charting in Excel 2 March 6th 06 04:05 PM
Grouping Vitruvius Excel Worksheet Functions 1 August 16th 05 09:07 PM
Grouping Peter Excel Programming 1 March 2nd 05 11:41 AM


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