Hi,
I need to switch the right and left borders in cells, and I'm not finding a good solution. The user will have various styles of borders per cell. Sometimes a cell might have a thick border on it's left while having a thin border on it's right. Sometimes they might have a thin border on the left, and no border on the right. I will need to switch the border styles to opposite sides.
I've been experimenting with this:
Dim selCell1 As Range
Set selCell1 = Cells(2, 2)
With selCell1
leftStyle = .Borders(xlEdgeLeft).LineStyle
leftWeight = .Borders(xlEdgeLeft).Weight
leftColor = .Borders(xlEdgeLeft).ColorIndex
rightStyle = .Borders(xlEdgeRight).LineStyle
rightWeight = .Borders(xlEdgeRight).Weight
rightColor = .Borders(xlEdgeRight).ColorIndex
.Borders(xlEdgeLeft).LineStyle = rightStyle
.Borders(xlEdgeLeft).Weight = rightWeight
.Borders(xlEdgeLeft).ColorIndex = rightColor
.Borders(xlEdgeRight).LineStyle = leftStyle
.Borders(xlEdgeRight).Weight = leftWeight
.Borders(xlEdgeRight).ColorIndex = leftColor
End With
But I'm finding that if one (or both) sides doesn't have a border, then the code is adding a thin border. For example, if I have a cell that originally has a thick border on the left, and no border on the right - after I run the code it does put the thick border on the right, but a thin border has been placed on the left!
My only other question is, is there more data I need to check for besides just linestyle, weight, and colorindex?
Thanks for looking at my questions. I'm working with Excel 14.1.4 on the Mac (10.7).
Jay
Bookmarks