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
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Code:
With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With

should do the trick
 
Upvote 0
After the borders are set to medium. Change the RightHand edge back to thin
Code:
Range("A2:K37").Borders(xlEdgeRight) Weight:=xlThin

lenze
 
Upvote 0
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!
 
Upvote 0

Forum statistics

Threads
1,214,877
Messages
6,122,051
Members
449,064
Latest member
scottdog129

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
Back
Top