#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Row Format by Group

I have a spreadsheet where column A contains a Product Group and it is sorted
in this order. Each Product Group may be on several Rows. I'd like to
change the colour of the row when the Product Group changes value. i.e.
similar to formatting alternate Rows but based on the change in value in
Column A...How?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default Row Format by Group

Hi Charlie

FormatConditional FormattingFormula is=$A2<$A1Formatchoose what you
want

--
Regards
Roger Govier

"Charlie Bamford" wrote in
message ...
I have a spreadsheet where column A contains a Product Group and it is
sorted
in this order. Each Product Group may be on several Rows. I'd like to
change the colour of the row when the Product Group changes value. i.e.
similar to formatting alternate Rows but based on the change in value in
Column A...How?


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Row Format by Group

Thanks Roger

This highlights the last row for each Group which helps but it doesn't go
quite as far as I would like. For example, all rows with Group 14DS should
be filled with yellow. The next 6 rows have Group 18AL. No fill is required
for these wows. After these comes Group 18BB and the fill should revert to
yellow etc.

Regards
Charlie

"Roger Govier" wrote:

Hi Charlie

FormatConditional FormattingFormula is=$A2<$A1Formatchoose what you
want

--
Regards
Roger Govier

"Charlie Bamford" wrote in
message ...
I have a spreadsheet where column A contains a Product Group and it is
sorted
in this order. Each Product Group may be on several Rows. I'd like to
change the colour of the row when the Product Group changes value. i.e.
similar to formatting alternate Rows but based on the change in value in
Column A...How?



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default Row Format by Group

Hi Charlie

I don't think you can do that with CF.

The following macro will probably achieve what you want.

Sub ColourRows()
Dim myrange As Range, userange As Range
Dim start As Range, finish As Range
Dim i As Long, j As Long, k As Long, lc As Long, lr As Long

Set myrange = ActiveSheet.UsedRange
lc = myrange.Columns.Count
lr = myrange.Rows.Count

i = 2
k = 1
Do While i < lr
Set start = Cells(i, 1)
j = WorksheetFunction.CountIf(Range(Cells(2, "A"), Cells(lr + 1,
"A")), start.Value)
Set userange = Range(Cells(i, 1), Cells(i + j - 1, lc))
userange.Select
If k = 1 Then
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
k = 0
Else
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
k = 1
End If
i = i + j
j = 0
Loop

End Sub

To insert the macro into your workbook.
Alt+F11 to invoke the VB Editor
InsertModule
Copy code above and Paste into white pane that appears
Alt+F11 to return to Excel

To use
Alt+F8 to bring up list of Macros
Highlight ColourRowsRun


--
Regards
Roger Govier

"Charlie Bamford" wrote in
message ...
Thanks Roger

This highlights the last row for each Group which helps but it doesn't go
quite as far as I would like. For example, all rows with Group 14DS
should
be filled with yellow. The next 6 rows have Group 18AL. No fill is
required
for these wows. After these comes Group 18BB and the fill should revert
to
yellow etc.

Regards
Charlie

"Roger Govier" wrote:

Hi Charlie

FormatConditional FormattingFormula is=$A2<$A1Formatchoose what you
want

--
Regards
Roger Govier

"Charlie Bamford" wrote in
message ...
I have a spreadsheet where column A contains a Product Group and it is
sorted
in this order. Each Product Group may be on several Rows. I'd like to
change the colour of the row when the Product Group changes value.
i.e.
similar to formatting alternate Rows but based on the change in value
in
Column A...How?



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default Row Format by Group

Sorry about the line wrap on one of the lines.
Substitute this

j = WorksheetFunction.CountIf(Range(Cells(2, "A"), _
Cells(lr + 1, "A")), start.Value)

--
Regards
Roger Govier

"Roger Govier" <roger@technology4unospamdotcodotuk wrote in message
...
Hi Charlie

I don't think you can do that with CF.

The following macro will probably achieve what you want.

Sub ColourRows()
Dim myrange As Range, userange As Range
Dim start As Range, finish As Range
Dim i As Long, j As Long, k As Long, lc As Long, lr As Long

Set myrange = ActiveSheet.UsedRange
lc = myrange.Columns.Count
lr = myrange.Rows.Count

i = 2
k = 1
Do While i < lr
Set start = Cells(i, 1)
j = WorksheetFunction.CountIf(Range(Cells(2, "A"), Cells(lr + 1,
"A")), start.Value)
Set userange = Range(Cells(i, 1), Cells(i + j - 1, lc))
userange.Select
If k = 1 Then
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
k = 0
Else
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
k = 1
End If
i = i + j
j = 0
Loop

End Sub

To insert the macro into your workbook.
Alt+F11 to invoke the VB Editor
InsertModule
Copy code above and Paste into white pane that appears
Alt+F11 to return to Excel

To use
Alt+F8 to bring up list of Macros
Highlight ColourRowsRun


--
Regards
Roger Govier

"Charlie Bamford" wrote in
message ...
Thanks Roger

This highlights the last row for each Group which helps but it doesn't go
quite as far as I would like. For example, all rows with Group 14DS
should
be filled with yellow. The next 6 rows have Group 18AL. No fill is
required
for these wows. After these comes Group 18BB and the fill should revert
to
yellow etc.

Regards
Charlie

"Roger Govier" wrote:

Hi Charlie

FormatConditional FormattingFormula is=$A2<$A1Formatchoose what
you
want

--
Regards
Roger Govier

"Charlie Bamford" wrote in
message ...
I have a spreadsheet where column A contains a Product Group and it is
sorted
in this order. Each Product Group may be on several Rows. I'd like
to
change the colour of the row when the Product Group changes value.
i.e.
similar to formatting alternate Rows but based on the change in value
in
Column A...How?




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Row Format by Group

Hi,

Thanks so much for this Roger, it has worked extremely well for my
spreadsheet too. I have one question ...

On my spreadsheet, the macro doesn't highlight the very last row. Is there
an adjustment that would allow me to keep the alternating colour pattern
going to include that last row?

Thanks in advance,
Scott

"Roger Govier" wrote:

Sorry about the line wrap on one of the lines.
Substitute this

j = WorksheetFunction.CountIf(Range(Cells(2, "A"), _
Cells(lr + 1, "A")), start.Value)

--
Regards
Roger Govier

"Roger Govier" <roger@technology4unospamdotcodotuk wrote in message
...
Hi Charlie

I don't think you can do that with CF.

The following macro will probably achieve what you want.

Sub ColourRows()
Dim myrange As Range, userange As Range
Dim start As Range, finish As Range
Dim i As Long, j As Long, k As Long, lc As Long, lr As Long

Set myrange = ActiveSheet.UsedRange
lc = myrange.Columns.Count
lr = myrange.Rows.Count

i = 2
k = 1
Do While i < lr
Set start = Cells(i, 1)
j = WorksheetFunction.CountIf(Range(Cells(2, "A"), Cells(lr + 1,
"A")), start.Value)
Set userange = Range(Cells(i, 1), Cells(i + j - 1, lc))
userange.Select
If k = 1 Then
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
k = 0
Else
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
k = 1
End If
i = i + j
j = 0
Loop

End Sub

To insert the macro into your workbook.
Alt+F11 to invoke the VB Editor
InsertModule
Copy code above and Paste into white pane that appears
Alt+F11 to return to Excel

To use
Alt+F8 to bring up list of Macros
Highlight ColourRowsRun


--
Regards
Roger Govier

"Charlie Bamford" wrote in
message ...
Thanks Roger

This highlights the last row for each Group which helps but it doesn't go
quite as far as I would like. For example, all rows with Group 14DS
should
be filled with yellow. The next 6 rows have Group 18AL. No fill is
required
for these wows. After these comes Group 18BB and the fill should revert
to
yellow etc.

Regards
Charlie

"Roger Govier" wrote:

Hi Charlie

FormatConditional FormattingFormula is=$A2<$A1Formatchoose what
you
want

--
Regards
Roger Govier

"Charlie Bamford" wrote in
message ...
I have a spreadsheet where column A contains a Product Group and it is
sorted
in this order. Each Product Group may be on several Rows. I'd like
to
change the colour of the row when the Product Group changes value.
i.e.
similar to formatting alternate Rows but based on the change in value
in
Column A...How?



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
how can i format a cell with 3 diffrent group to add JMGRC Charts and Charting in Excel 0 October 26th 06 10:49 AM
Taking age group Ie ages 20-29 and picking out net sales for group viabello Excel Worksheet Functions 1 April 25th 06 04:19 AM
group comment format on text wildlysa Excel Worksheet Functions 1 January 29th 06 02:14 AM
format group of rows based on condition Aaron Excel Discussion (Misc queries) 0 January 10th 06 12:29 AM
How do I group worksheets (Lotus 123 function is "Sheet>Group Shee jaking Excel Worksheet Functions 2 August 30th 05 02:09 PM


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