+ Reply to Thread
Results 1 to 3 of 3

Modify macro to highlight max&min values

  1. #1
    Forum Contributor
    Join Date
    04-30-2011
    Location
    wirral,england
    MS-Off Ver
    Excel 2010
    Posts
    148

    Modify macro to highlight max&min values

    Re revised macro: Max & min values highlighted by font colour.
    This macro refers to a previous post on 05-10-2011 Max & min values highlighted by font colour the problem was solved but the data has been moved to new cell locations and i would like to know if Is it possible to modify the revised macro to reflect revised column numbers and additional columns to be highlighted for max and min values
    .A B C D E f-g T -AF ag-ai AJ AK AL AM AN
    date sad name course time

    The changes from the original spreadsheet (where the range was p2:w2 are an additional heading added and these headings are now moved to cols A-E,cols f to g and ag to ai contain no data for highlighting.Cols T to AF and AJ to AN contain ratings to be highlighted as per the original query

    Set Rng = Rng.Resize(RowSize:=RngEnd.Row - Rng.Row + 1)

    Application.ScreenUpdating = False

    StartRow = 1

    For R = 1 To Rng.Rows.Count

    GroupName = Rng.Item(R, 1) & Rng.Item(R, 3) & Rng.Item(R, 4)
    NextName = Rng.Item(R + 1, 1) & Rng.Item(R + 1, 3) & Rng.Item(R + 1, 4)

    If GroupName <> NextName Then
    Set GroupRng = Rng.Item(StartRow, 5).Resize(R - StartRow + 1, 4)

    For I = 1 To 4
    MinRate = WorksheetFunction.Min(GroupRng.Columns(I))
    MaxRate = WorksheetFunction.Max(GroupRng.Columns(I))
    For J = 1 To GroupRng.Rows.Count
    Select Case GroupRng.Item(J, I)
    Case MinRate
    GroupRng.Item(J, I).Font.Color = vbGreen
    Case MaxRate
    GroupRng.Item(J, I).Font.Color = vbRed
    End Select
    Next J
    Next I

    StartRow = R + 1
    End If

    Next R

    Application.ScreenUpdating = True

    End SubAttached Files Color Min and Max Values ver 1a.xls (35.5 KB, 4 views)



    _________________

    Many thanks for any help

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,946

    Re: Modify macro to highlight max&min values

    Please add CODE Tags or you won't get any replies.

    And it would help if you posted a sample workbook so the code could be seen in context.


    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Modify macro to highlight max&min values

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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