TheWennerWoman
Active Member
- Joined
- Aug 1, 2019
- Messages
- 303
- Office Version
- 365
- Platform
- Windows
I've got about 1 row x 250 columns of data which are coloured alternately to make things easier to read. If I insert a column half way along, I have to go through and manually change the cell colours. I started off with this but haven't managed to finish it
I could wrap a DO....WHILE loop around to quit when the value of b is reached.
My query is: some of the cells in row 4 are merged so simply adding 1 to the variable a each time is going to error at some point. Is there a way of doing this?
Thanks in advance.
VBA Code:
Sub alternate_colours()
a = 334 ' column LV
b = 571 ' column UY
Cells(4, a).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Cells(4, a + 1).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
End Sub
I could wrap a DO....WHILE loop around to quit when the value of b is reached.
My query is: some of the cells in row 4 are merged so simply adding 1 to the variable a each time is going to error at some point. Is there a way of doing this?
Thanks in advance.