Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Alternate row highlighting with a difference

I get a daily report which I would like to make easier to read b
highlighting each set of row data alternately in different colour
according to the value in the first column

I.e.

a
a
a
a
b
b
b
b
c
c
d
d
d

All the rows where A = "a" would be in grey, then where A = "b", n
colour, then where A ="c" would be back to grey again and so on.

Much appreciate any help or advice available on this.

T

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Alternate row highlighting with a difference

TW,

Try the macro below.

HTH,
Bernie
MS Excel MVP

Sub AlternateGreyBasedOnColumnA()
'Written by Bernie Deitrick
Dim myCell As Range
Dim IsGrey As Boolean

IsGrey = False

For Each myCell In Intersect(Range("A:A"), ActiveSheet.UsedRange)
If myCell.Row = 1 Then
With Intersect(Rows("1:1"), ActiveSheet.UsedRange)
With .Interior
.ColorIndex = 15
.Pattern = xlSolid
IsGrey = True
End With
End With
Else
If myCell.Value < myCell(0).Value Then
With Intersect(myCell.EntireRow, ActiveSheet.UsedRange)
With .Interior
.ColorIndex = IIf(IsGrey, xlNone, 15)
.Pattern = xlSolid
IsGrey = Not IsGrey
End With
End With
Else
With Intersect(myCell.EntireRow, ActiveSheet.UsedRange)
With .Interior
.ColorIndex = IIf(IsGrey, 15, xlNone)
.Pattern = xlSolid
End With
End With
End If
End If
Next myCell

End Sub



"twaccess " wrote in message
...
I get a daily report which I would like to make easier to read by
highlighting each set of row data alternately in different colours
according to the value in the first column

I.e.

a
a
a
a
b
b
b
b
c
c
d
d
d

All the rows where A = "a" would be in grey, then where A = "b", no
colour, then where A ="c" would be back to grey again and so on.

Much appreciate any help or advice available on this.

TW


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Alternate row highlighting with a difference

Fantastic Bernie !

It works a treat, I'm going to add it to another macro which works o
the same report by removing unwanted columns and resizing column
etc...

Good to hear from you again.

Regards


Terr

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Alternate row highlighting with a difference

Bernie..

a bit shorter wouldn't do it any harm :)

Sub AlternateGreyBasedOnColumnA()
'Alternative by keepITcool
Dim r&, Toggle As Boolean
With ActiveSheet.UsedRange
For r = 1 To .Rows.Count
With .Rows(r).Interior
If Toggle Then
.Pattern = xlNone
Else
.ColorIndex = 15
End If
End With
If .Cells(r, 1) < .Cells(r + 1, 1) Then Toggle = Not Toggle
Next
End With

End Sub

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Bernie Deitrick" <deitbe @ consumer dot org wrote:

Sub AlternateGreyBasedOnColumnA()
'Written by Bernie Deitrick
Dim myCell As Range
Dim IsGrey As Boolean

IsGrey = False

For Each myCell In Intersect(Range("A:A"), ActiveSheet.UsedRange)
If myCell.Row = 1 Then
With Intersect(Rows("1:1"), ActiveSheet.UsedRange)
With .Interior
.ColorIndex = 15
.Pattern = xlSolid
IsGrey = True
End With
End With
Else
If myCell.Value < myCell(0).Value Then
With Intersect(myCell.EntireRow, ActiveSheet.UsedRange)
With .Interior
.ColorIndex = IIf(IsGrey, xlNone, 15)
.Pattern = xlSolid
IsGrey = Not IsGrey
End With
End With
Else
With Intersect(myCell.EntireRow, ActiveSheet.UsedRange)
With .Interior
.ColorIndex = IIf(IsGrey, 15, xlNone)
.Pattern = xlSolid
End With
End With
End If
End If
Next myCell

End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Alternate row highlighting with a difference

keepITcool

I was waaaay too busy to optimize the code - just got it to work, as it
looked like there wasn't going to be a response....

Bernie

a bit shorter wouldn't do it any harm :)





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Alternate row highlighting with a difference

Thanks Guys

Routine is embedded in my report tidy up macro complete with button o
my menu bar too.

All is working just fine too, I've just run it on a report I receive
this morning.

Regards


Terr

--
Message posted from http://www.ExcelForum.com

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
Alternate row comparison GB3 Excel Worksheet Functions 11 December 27th 09 10:42 AM
Highlighting cell on value difference. Neil Excel Discussion (Misc queries) 1 December 14th 09 04:25 PM
Highlighting alternate rows NicoleS Excel Discussion (Misc queries) 8 June 18th 09 01:26 AM
Highlighting blanks via GO TO SPECIAL is not highlighting blank cells - HELP, I'm totally stuck. Jamie Furlong Excel Discussion (Misc queries) 6 August 28th 05 09:27 PM
charting a difference of 2 columns' w/o adding a difference column Wab Charts and Charting in Excel 4 July 27th 05 02:37 AM


All times are GMT +1. The time now is 12:13 PM.

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"