Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / June 2006

Tip: Looking for answers? Try searching our database.

condense code for gridelines

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SITCFanTN - 30 Jun 2006 13:23 GMT
Is there a way to shorten this code a bit.  I recorded this macro and just
feel there is a way to condense it, I'm just not sure how.  All I'm trying to
do is add grid lines to my sheet.  This macro formats about 2 dozen pages so
the less code the better. Thanks

Columns("A:H").Select
   Selection.Borders(xlDiagonalDown).LineStyle = xlNone
   Selection.Borders(xlDiagonalUp).LineStyle = xlNone
   With Selection.Borders(xlEdgeLeft)
       .LineStyle = xlContinuous
       .Weight = xlThin
       .ColorIndex = xlAutomatic
   End With
   With Selection.Borders(xlEdgeTop)
       .LineStyle = xlContinuous
       .Weight = xlThin
       .ColorIndex = xlAutomatic
   End With
   With Selection.Borders(xlEdgeBottom)
       .LineStyle = xlContinuous
       .Weight = xlThin
       .ColorIndex = xlAutomatic
   End With
   With Selection.Borders(xlEdgeRight)
       .LineStyle = xlContinuous
       .Weight = xlThin
       .ColorIndex = xlAutomatic
   End With
   With Selection.Borders(xlInsideVertical)
       .LineStyle = xlContinuous
       .Weight = xlThin
       .ColorIndex = xlAutomatic
   End With
   With Selection.Borders(xlInsideHorizontal)
       .LineStyle = xlContinuous
       .Weight = xlThin
       .ColorIndex = xlAutomatic
   End With
britwiz@hotmail.com - 30 Jun 2006 14:31 GMT
> Is there a way to shorten this code a bit.  I recorded this macro and just
> feel there is a way to condense it, I'm just not sure how.  All I'm trying to
> do is add grid lines to my sheet.  This macro formats about 2 dozen pages so
> the less code the better. Thanks

Hi SITCFanTN

Try:

Columns("A:H").Borders.LineStyle = xlContinuous

Regards

Steve
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.