Brian has attended:
Excel VBA Intro Intermediate course
Inside Thin and Outside Thick Borders CurrentRegion
Hi
Please can you advise how you go about making the currentregion inside borders to be think without the outside border of the currentregion to have thick borders.
The macro record code seems to have every edge of the border and presume there is a neater solution using the with command.
Thanks
Brian
RE: Inside Thin and Outside Thick Borders CurrentRegion
Hi Brian, thanks for your query and apologies for the delay. My attempt with the macro recoder yields the following which I would tidy up into one With expression. You can see you need to be specific about which borders to format, and in the case of borders I would code the default settings to "format over" any formatting already on the sheet. Here's the code:
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
End Sub
Hope this helps,
Anthony
RE: Inside Thin and Outside Thick Borders CurrentRegion
Hi Anthony,
I have managed to find out the code online and thought i'd update the post for anyone looking in.
With Selection
.Borders.Weight = xlThin
.BorderAround Weight:=xlThick
End With
Thanks
Brian