VBA borderaround question

Zanatos

Board Regular
Joined
May 18, 2007
Messages
65
I had used borderaround to make the border of a section of cells the same to send to a printable sheet, and upon closing it set it to get the border back to normal (code shown)



Private Sub CommandButton3_Click() ' Preview Whole Sheet
Application.ScreenUpdating = False ' Turn monitor refresh off
Range("DetailsMS").Select
Range("A2:K37").BorderAround Weight:=xlThin
ActiveSheet.PageSetup.PrintArea = "DetailsMS"
With ActiveSheet.PageSetup

(code here deleted for thread.. not important to question)

End With
ActiveWindow.SelectedSheets.PrintPreview
Range("A2:K37").BorderAround Weight:=xlMedium
Columns("A:A").Select
Range("B6").Activate
Application.ScreenUpdating = True ' Turn monitor refresh on


Anyways, when I change the back the border, I only want three sides to be changed, the right hand side of border needs to stay at the thin weight, is there a command that can change just one side of border?

Thanks
 

Some videos you may like

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Makrini

Well-known Member
Joined
May 22, 2007
Messages
1,035
Code:
With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With

should do the trick
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
After the borders are set to medium. Change the RightHand edge back to thin
Code:
Range("A2:K37").Borders(xlEdgeRight) Weight:=xlThin

lenze
 

Zanatos

Board Regular
Joined
May 18, 2007
Messages
65
Thanks for the help guys, Makrini, the code worked perfect. Lenze, whenever I was trying yours (liked the fact that it was short) the word 'Weight' was highlighting giving it an error, no big deal just thought I would say something for someone else who may read this.

Thanks again!
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Code:
Range("A2:K37").Borders(xlEdgeRight).Weight = xlThin
 

Watch MrExcel Video

Forum statistics

Threads
1,122,463
Messages
5,596,284
Members
414,051
Latest member
tabecker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top