+ Reply to Thread
Results 1 to 4 of 4

Pivot table conditional formatting using VBA

  1. #1
    Registered User
    Join Date
    06-09-2016
    Location
    UK
    MS-Off Ver
    Office 2016
    Posts
    2

    Pivot table conditional formatting using VBA

    Hi, I am new to the forum and relatively inexperienced in VBA.

    I need some enhancements to my code below which looks for a value of 999 in any cell and changes the fill color to green.

    Not only do I need to change the fill color but I need to change the cell value of 999 into a text string e.g. "Unavailable"

    I also need to repeat the conditional formatting for several cell values e.g.
    Formula1:="888" would change the cell value to "Available"
    Formula1:="777" would change the cell value to "Other"
    Formula1:="666" would change the cell value to "Not known"

    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 06-09-2016 at 02:46 PM.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Pivot table conditional formatting using VBA

    conditional formatting does not change the value of the cell only the formatting

    to change the value you need to change the source data itself or add to the source data ie use a helper column
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    06-09-2016
    Location
    UK
    MS-Off Ver
    Office 2016
    Posts
    2

    Re: Pivot table conditional formatting using VBA

    Hi, thanks very much for getting back to me.

    I have managed to get further with this by adding Selection.NumberFormat = "[=999]""Available"";;" to my procedure after recording this in a macro (used a custom number format).

    This works fine for 999 = Available but I now need to add other conditions in some kind of loop if anyone can suggest a neat way of repeating with different conditions.

    New code tagged.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Pivot table conditional formatting using VBA

    Please Login or Register  to view this content.
    cant really loop unique number formats like yours
    you can loop for same colorindex
    i've illustrated the difference in the above code

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 9
    Last Post: 03-07-2016, 10:39 AM
  2. Replies: 2
    Last Post: 09-04-2015, 02:47 AM
  3. Replies: 1
    Last Post: 02-04-2015, 10:33 PM
  4. Pivot Table Conditional Formatting
    By excelhelporfavor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-15-2014, 05:00 AM
  5. [SOLVED] Pivot Table - Conditional Formatting
    By lewny1983 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2012, 04:51 AM
  6. Conditional Formatting a pivot table
    By thestappa in forum Excel General
    Replies: 0
    Last Post: 09-01-2010, 04:04 PM
  7. conditional formatting in pivot table
    By sach0025 in forum Excel General
    Replies: 7
    Last Post: 02-02-2007, 03:19 AM

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