How to create a page border in Excel with VBA



How to create a page border in Excel with VBA
Automatically create a page border on any worksheet in Excel. Create a thick border around the edge of the printed page.
Check out my online courses

Code
Sub Page_borders()
Dim rngBorder As Range
Dim lngLastRow As Long
Dim lngLastCol As Long
Dim fstRow As Long
Dim fstCol As Long
Dim printRng As Range

Set printRng = Range(“A1:I46”)

lngLastRow = printRng.Row + printRng.Rows.Count – 1
lngLastCol = printRng.Column + printRng.Columns.Count – 1

With ActiveSheet

fstRow = 1
fstCol = 1

Set rngBorder = .Range(.Cells(fstRow, fstCol), .Cells(lngLastRow, lngLastCol))
rngBorder.BorderAround xlContinuous, xlThick

End With
End Sub

For more help visit my website or email me at easyexcelanswers@gmail.com.

Contact me regarding customizing this template for your needs.

Excel one-on-one on-line training available. Email me to arrange.

I am able to provide online help on your computer at a reasonable rate.

Check out my next one-hour Excel Webinar

I use a Blue condensor Microphone to record my videos, here is the link

Check out Crowdcast for creating your webinars

If you need to buy Office 2019 follow

I use Tube Buddy to help promote my videos
Check them out

Follow me on Facebook

Follow me on twitter
easyexcelanswers

IG @barbhendersonconsulting

You can help and generate a translation to you own language

*this description may contain affiliate links. When you click them, I may receive a small commission at no extra cost to you. I only recommend products and services that I’ve used or have experience with.

Watch more new videos about Excel Office | Synthesized by Mindovermetal English

Rate this post

Bài viết liên quan

Theo dõi
Thông báo của
guest
2 Comments
Cũ nhất
Mới nhất Được bỏ phiếu nhiều nhất
Phản hồi nội tuyến
Xem tất cả bình luận
Angel Linares

Great video, though I'm having trouble trying to tweak this script in order to work for all active pages in a worksheet.

Srikanta Bhoi

How make no page