Hi All,
I am using the below code to create partition / applying borders in range A4:L4 down till the last non empty cell whenever a value changes in Column B.
What i want is a code to fill colors in cells where the code is creating partition / applying borders.
For example:
2
2 This partition to turn color 1
2 _______________________
3
3 This partition to turn color 2
3 ______________________
4 ______________________This partition to turn color 1
5
5 This partition to turn color 2
5 ______________________
6
6 This partition to turn color 1
6 ______________________
The data is not constant so i run the code everytime the data changes.
The borders are created with the code mentioned above. I would want the code to fill colors also.
An addition or ammendment in the current code or a new code would do.
Any help would be appreciated.
Regards,
I am using the below code to create partition / applying borders in range A4:L4 down till the last non empty cell whenever a value changes in Column B.
Code:
[COLOR=#333333]Sub Test() [/COLOR]
Dim LastRow As Long
LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Dim rng As Range
For Each rng In Range("B4:B" & LastRow)
If rng <> rng.Offset(1, 0) Then
Range("A" & rng.Row & ":L" & rng.Row).Borders(xlEdgeBottom).LineStyle = xlContinuous
Range("A" & rng.Row & ":L" & rng.Row).Borders(xlEdgeBottom).Weight = xlMedium
End If
Next rng
[COLOR=#333333]End Sub[/COLOR]
What i want is a code to fill colors in cells where the code is creating partition / applying borders.
For example:
2
2 This partition to turn color 1
2 _______________________
3
3 This partition to turn color 2
3 ______________________
4 ______________________This partition to turn color 1
5
5 This partition to turn color 2
5 ______________________
6
6 This partition to turn color 1
6 ______________________
The data is not constant so i run the code everytime the data changes.
The borders are created with the code mentioned above. I would want the code to fill colors also.
An addition or ammendment in the current code or a new code would do.
Any help would be appreciated.
Regards,