![]() |
Format Looping
Hi all,
I'm trying to set up a code - a loop whereby every time the value of cells (x,3) changes the cell pattern changes alternately from being shaded in grey and no colour. Not sure how to write it so that it does what i need. So for example if i had a s/s with John John Jim Jim Jim Fred It would colour john cells in Grey shading, Jim - no colour shading and Fred Grey Shading again. Sheets("Sheet1").Select x = 3 Do Until Cells(x, 3).Value = "" If Cells(x, 3).Value = Cells(x - 1, 3).Value and ...... Then ..... x = x + 1 Else if cells( Can anyone help? Thanks. |
Format Looping
Hi Crauwf,
In Excel 2003 I have created this: Sub toggleFillColor() Dim x As Long Dim b As Boolean ' remove fillcolor Range("C:C").Interior.ColorIndex = xlNone x = 2 b = False Do Until IsEmpty(Cells(x, 3)) If Cells(x, 3).Value < Cells(x - 1, 3).Value Then b = Not b End If If b Then With Cells(x, 3).Interior .ColorIndex = 15 .Pattern = xlSolid End With End If x = x + 1 Loop End Sub HTH, Wouter |
Format Looping
Thanks, that's an absolutely immense code. Thanks for your help!!!
"RadarEye" wrote: Hi Crauwf, In Excel 2003 I have created this: Sub toggleFillColor() Dim x As Long Dim b As Boolean ' remove fillcolor Range("C:C").Interior.ColorIndex = xlNone x = 2 b = False Do Until IsEmpty(Cells(x, 3)) If Cells(x, 3).Value < Cells(x - 1, 3).Value Then b = Not b End If If b Then With Cells(x, 3).Interior .ColorIndex = 15 .Pattern = xlSolid End With End If x = x + 1 Loop End Sub HTH, Wouter |
All times are GMT +1. The time now is 06:36 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com