I want to add borders to a range depending on the value in the "a" column.
Normally I want a left border in cell "a", a right border in cell "h" and bottom border in cells "a" to "h".
However if the value in cell "a" is the same as the cell below I do not want the bottom border.
Cell "a" contains the names of customers using our facilities each day. Some customers use several facilities on the same day. I want the borders to encompass all facilities used by each customer per day e.g. range "a1:h8" might need bottom borders on all rows, because they are single customers using only one facility that day but ranges "a9:h11" would require bottom borders only on row 11, because that customer is using three of our facilities that day.
I found this thread:-
http://www.excelforum.com/excel-prog...condition.html
and amended part of it to read:-
Set Rng = ActiveSheet.Range("a:h").SpecialCells(xlCellTypeConstants)
change the Range to "a:h"
and:-
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
set the three borders.
But when I run it I get a left border only in cells in the "g" column only if the cell contains a value and a bottom border if the cell is the last to have a value.
I take I don't need the code:-
If Not Rng Is Nothing Then
For Each aRng In Rng.Areas
CreateBorder aRng
Next
End If
but something else to pick up my whole range but modified for matching values?
Can anyone please advise?
Bookmarks