+ Reply to Thread
Results 1 to 7 of 7

Border of cells around pivot table

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Border of cells around pivot table

    I have a pivot table that's refreshed every time the sheet is activated. The design desired on the PT sheet is to have the cells around the pivot to be green, while the pivot remains uncolored, and the rest of the sheet other than the green border stays uncolored (or, stays the various colors it is). I've included an example of the desired result.

    The problem is that, depending on the PT's source data, the pivot can be only a few rows deep, or many rows deep. Adding or removing a field, or changing the number of rows, changes where the green should be, so I need a macro tha can keep up with it. Can anyone point me in the right direction?
    Attached Files Attached Files

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Border of cells around pivot table

    HI jomili,

    Pivot can grow only downwards or towards right as well ?

    I believe you can use conditional formatting using offset / defined names to obtain green boarder and after that it all untouched cells.


    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Border of cells around pivot table

    I don't understand how I could use conditional formatting in this situation. Can you explain further?

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Border of cells around pivot table

    perhaps name the green area around the pivot table (including the pivot table itself) "pivotBorder" then add this code to the sheet

    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Border of cells around pivot table

    JosephP,
    Again you save me! That works perfectly.

    Can you explain the reasoning behind this line of code? I don't understand the reason for .Offset, though I can recognize offsetting -2, then adding 8 to row count ends up with 6 rows colored.
    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Border of cells around pivot table

    The offset is declaring the point in which to start the resize function.

    So, if you're table starts at C3, the offset is telling you to go to A2, and then add in the rows (+8) and all the columns (+2)... This is basically setting how far up and how far to the left the border starts.

    Hope that helps!
    Going for Guru! Click the Star to the bottom left of this post if I helped!

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Border of cells around pivot table

    Thanks so much, for the help AND the explanation. I surely appreciate both!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1