PDA

View Full Version : Macro to format borders within tables in Excel file



KP_SoCal
10-29-2011, 09:30 PM
:help
A link posted in another thread on this site comes very close to what I'm trying to accomplish in my worksheet. Since I'm unable to post the link in my description, I listed it in the attached Excel file.

If you open my attached file, you'll see exactly what I'm trying to accomplish concerning the borders. Any help is greatly appreciated. Thanks!

Kenneth Hobs
10-30-2011, 04:34 PM
Welcome to the forum!

I don't see the problem. The Sub xlBorders provided in the kb article, http://www.vbaexpress.com/kb/getarticle.php?kb_id=499, is pretty straight forward. Just put the Sub into a module or copy the whole module as use what you need.

Like the examples, just tell your Sub to call it and pass the 3 required input parameters. For example, inserting an ActiveX commandbutton via the Developer tab, the code for the active sheet's used range would be:
Private Sub CommandButton1_Click()
xlBorders ActiveSheet.UsedRange, "thick", "thin"
End Sub