+ Reply to Thread
Results 1 to 10 of 10

Highlight 3 highest value in a row

  1. #1
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Highlight 3 highest value in a row

    Hi experts,

    I need a VBA to automatically change the font color of the 3 highest values in a row..these rows may include rows in a pivot table..and i would like that i'll be able to change the number of values to highlight from time to time (say 5 highest values, 6 highest values etc.)

    I tried using conditional formatting with this formula =A1>=LARGE($A1:$T1,3) but the reference cells keeps on changing when a pivot table updates.

    Please help

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Highlight 3 highest value in a row

    I'd use with a worksheet change or selection change event. This code goes directly on the sheet it applies to.

    This code is for Rows 1 to 25. Adjust range to fit your need.

    Please Login or Register  to view this content.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Highlight 3 highest value in a row

    is there a way to speed up the macro?

    Please take note that the pivot tables are connected to one pivot table who is refreshed via worksheet activate.

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Highlight 3 highest value in a row

    Then I'd call this subroutine from within that one, near the end, instead of using another event.

    Please Login or Register  to view this content.
    Last edited by daffodil11; 04-03-2015 at 05:19 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Highlight 3 highest value in a row

    Is there a way to have the macro read only until the last row with data?

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Highlight 3 highest value in a row

    What do you mean read only? Do you wish to only add new formatting to the last row?

  7. #7
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Highlight 3 highest value in a row

    i wish the macro to run from a specific starting row and end on the last row with the data..

    so basically we'll start on row 7 and then the last row will vary every time the pivot table is updated.

    so the macro won't be specific to a certain number of rows e.g. For i = 7 to 25

  8. #8
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Highlight 3 highest value in a row

    Oh, of course.

    First we have to know what column that last row will appear on. Let's pretend you will always have data in Column D.

    Please Login or Register  to view this content.
    That last part start at D, counts the rows in the worksheets (1.04 million) and then moves upwards until it hits the first occupied cell.

    So if you last occupied cell is D23, this will run for row 7 to 23. It will dynamically update itself each time.

  9. #9
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Highlight 3 highest value in a row

    thank you so much sir.. appreciate your help

  10. #10
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Highlight 3 highest value in a row

    No problem. Also might help if you slide the delete up front, so that old formatting is removed if less data is present.


    Please Login or Register  to view this content.

+ 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. Highlight highest value in each column
    By E2Lis in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-26-2013, 04:47 PM
  2. [SOLVED] Highlight highest lowest value every nth row in a column
    By Cicada in forum Excel General
    Replies: 8
    Last Post: 02-04-2013, 02:22 PM
  3. [SOLVED] Highlight second highest values, problem with ties
    By Djimidimi in forum Excel General
    Replies: 12
    Last Post: 06-07-2012, 10:47 AM
  4. [SOLVED] Highlight highest value
    By jjay2109 in forum Excel General
    Replies: 4
    Last Post: 05-09-2012, 07:04 PM
  5. Replies: 6
    Last Post: 10-19-2009, 06:59 PM

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