Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
alternate row shading kept with autofilter | Excel Discussion (Misc queries) | |||
Shading row based on value in one of its columns | Excel Discussion (Misc queries) | |||
Alternate row shading with a filtered spreadsheet | Excel Discussion (Misc queries) | |||
Alternate shading colors | Excel Discussion (Misc queries) | |||
Alternate Shading | Excel Discussion (Misc queries) |