+ Reply to Thread
Results 1 to 7 of 7

Using LARGE & Keeping the Source Format

  1. #1
    Registered User
    Join Date
    03-04-2008
    Posts
    34

    Using LARGE & Keeping the Source Format

    Hi all,

    Through this forum I recently learned how to use the LARGE function. It's really great, but now I have a different issue. I'm using the LARGE function to sort a table of data. Each row of the data source is color coded, and as I sort via the LARGE function, I also need to pull the color code from the data source.

    One row from the data source table is dynamic, so the sorted columns change with that one row. That being the case, I need the colors to change appropriately. I'm not sure what I need to do to make that happen. Basically, everytime the workbook is used, the data changes, so the sorting changes and the colors of each cell should change, but they don't. Any help would be great.
    Thanks.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon MAMC84

    There are numerous ways of finding the ColorIndex of a cell, however as these cell colours are changing dynamically, I would suspect that you're using conditional formatting. If this is the case then it's not really possible to pick up the colours, as it doesn't use the standard ColorIndex function.

    You will have to use a way if determining what colour the cell is by applying the same conditions as the conditional formulae in a standard formula.

    Chip Pearson provides some functions here, which interogate the FormatConditions object to check for a possible match - you might find this useful.
    http://www.cpearson.com/Excel/CFColors.htm

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    03-04-2008
    Posts
    34

    Over my head

    Hi DominicB,

    Thank you for the link, I'll continue to read through it, but I have to say I have no idea what is required.

    You said, "You will have to use a way if determining what colour the cell is by applying the same conditions as the conditional formulae in a standard formula."

    Can you please elaborate?

    Thank you.

  4. #4
    Registered User
    Join Date
    03-04-2008
    Posts
    34
    DominicB & Any one else interested & willing:

    Attached is a tiny sample of what I'm working with.

    If at all possible, please help me to understand how I can utilize the Large function and pull the proper color. Column A in this attachment uses the large function to sort data in column C.

    I suppose the workaround is to create macros to copy the data and sort, but if it can be automated without use of macros, it is better.

    Thanks!
    Attached Files Attached Files

  5. #5
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi MAMC84

    The colours appear to have been done by hand, not as conditional formatting, which means that my original answer is unsuitable. Also functions (even user defined functions) cannot be used to alter the format of a cell.

    Therefore the only option you have open to you is to resort to VBA, which must be done after the event. The formula in place will alter dynamically as the values in column C change, but once this is complete the macro can colour the correct cells accordingly.

    HTH

    DominicB
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    03-04-2008
    Posts
    34

    Thanks

    I'll use macros and the users will have to suffer through them too. It's not that bad... Thank you for your help.

  7. #7
    Registered User
    Join Date
    03-04-2008
    Posts
    34

    VBA Help

    Thank you DominicB for giving me this VBA code. I thought I'd be able to figure out how to adjust it for my worksheet. Apparently, I am not that bright. Can someone please help? I have two tables with ranges, B3 to I11, and B15 to I23. The first table is pulling from L3 to S11, and the second pulls from L15 to S23. Thank you for helping!

    Sub test()
    a = Selection(1).Row
    For n = a To Selection.Count + a
    For f = a To Selection.Count + a
    If Cells(n, 1).Value = Cells(f, 3).Value Then
    Cells(n, 1).Interior.ColorIndex = Cells(f, 3).Interior.ColorIndex
    End If
    Next f
    Next n
    End Sub

+ 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