Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Alternate shading based on series of numbers in 3 columns

Hi again Peter,

The code worked a treat.

I really do appreciate the time and effort you have put in.

We got there in the end..... <g

Many Thanks,

Cheers

Bob

On Mon, 19 Sep 2005 17:33:37 +0100, "Peter T" <peter_t@discussions
wrote:

Hi Bob,

OK I think I get it now. As much me having been slow to understand as you
not to have explained. <g

Hopefully following will do what you originally asked for, ie the shading

Option Explicit
Sub test()
Dim b1 As Boolean, b2 As Boolean
Dim rbRow As Long
Dim rtRow As Long
Dim i As Long
Dim v
Dim rng As Range

With Range("F15")
rtRow = .Row
rbRow = .End(xlDown).Row
v = Range(Cells(rtRow, .Column), Cells(rbRow, .Column + 2)).Value
Set rng = Range(Cells(rtRow, 1), Cells(rbRow, .Column + 2))
End With
rtRow = rtRow - 1

rng.Interior.ColorIndex = xlNone
rng.Rows(1).Interior.ColorIndex = 6

b1 = True
For i = 2 To UBound(v)
b2 = v(i, 1) = v(i - 1, 1) And _
v(i, 2) = v(i - 1, 2) And _
v(i, 3) = v(i - 1, 3)

If b1 = b2 Then
Range(Cells(rtRow + i, 1), Cells(rtRow + i, 8)).Interior.ColorIndex = 6
End If

If b2 = False Then
b1 = Not b1
End If
Next

End Sub

If you want to insert rows beteen bands instead of shading, adapt the above
but loop from the bottom, ie

For i = ubound(v) - 1 to 1 step -1
and compare v(i, 1) = v(i +1, 1) , etc
When you get to a "switch" insert a row and continue

Regards,
Peter T



<Big Snip







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 shading kept with autofilter Valeria Excel Discussion (Misc queries) 3 April 21st 10 11:51 PM
Shading row based on value in one of its columns EAPS Excel Discussion (Misc queries) 1 July 14th 09 10:19 PM
Alternate row shading with a filtered spreadsheet glenlee Excel Discussion (Misc queries) 5 December 9th 06 05:57 AM
Alternate shading colors tjsmags Excel Discussion (Misc queries) 2 September 4th 06 02:49 PM
Alternate Shading tamiluchi Excel Discussion (Misc queries) 9 April 28th 06 08:55 PM


All times are GMT +1. The time now is 04:02 AM.

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"