inside thin and outside

Public Schedule Face-to-Face & Virtual Instructor-Led Training - View dates & book

Forum 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

resolvedResolved · 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 courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Changing Excel file and worksheet defaults

The 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.

By opening, modifying and saving these templates you can change the default settings for all new files and/or all newly inserted sheets.

Use Book.xlt to make change to defaults for new workbooks; and Sheet.xlt to change defaults for sheets.

If you can't find either of these files on your computer, you can create and save them yourself.

You can do this simply by creating a new workbook with the setting you want to use as your defaults; then saving them with the appropriate name in the XLStart folder. If you are using Office 2003, this is usually found in C:\Program Files\Microsoft Office\Office11\XLStart.

View all Excel hints and tips


Server loaded in 0.06 secs.