98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Inside Thin and Outside Thick Borders CurrentRegion
Inside Thin and Outside Thick Borders CurrentRegion
Resolved · High Priority · Version 2003
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
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Changing Excel file and worksheet defaultsThe appearance of any new Excel files or any new worksheets that are inserted into a file are controlled by two template files, Book.xlt and Sheet.xlt. |