Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Code to add gridlines to Excel Pivot Tables

This was more cumbersome than I realized (at least with Excel 2003). I found
this code on another forum and it works like a charm:

Here's the link to the post
http://lounge.windowssecrets.com/ind...owtopic=737024

Here's the post itself:

You can create code that will format the pivot table automatically each time
it is updated:
- Right-click the sheet tab of the worksheet that contains the pivot table.
- Copy/paste the following code into the worksheet module:

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
With Target.TableRange1.Borders
..LineStyle = xlContinuous
..ColorIndex = xlColorIndexAutomatic
..Weight = xlThin
End With
End Sub

- Modify as needed; you can change the style, color and width of the
borders, for example.
- The above code will apply borders to the entire pivot table except the
page field (if present).
- If you want to include the page field, use TableRange2 instead of
TableRange1.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel pivot tables douglas Setting up and Configuration of Excel 1 December 19th 09 09:33 AM
Building pivot tables in Excel 2007 based on existing pivot tables? [email protected] Excel Discussion (Misc queries) 4 December 26th 07 08:05 PM
VBA Code with Pivot tables [email protected] Excel Discussion (Misc queries) 2 April 19th 07 05:21 PM
In Excel, gridlines won't print--File,PageSetup,Sheet,Gridlines-- 4most New Users to Excel 3 July 9th 06 01:45 AM
Excel Pivot Tables Brent_in_Oregon Excel Discussion (Misc queries) 0 December 9th 05 11:16 PM


All times are GMT +1. The time now is 10:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"