+ Reply to Thread
Results 1 to 7 of 7

Discerning Cell Formatting

  1. #1
    Registered User
    Join Date
    07-15-2010
    Location
    California, United States
    MS-Off Ver
    Excel 2010
    Posts
    45

    Discerning Cell Formatting

    Is there a quick way to tell which cells are formatted to which type when you have formatted many cells with different formattings? I know that in the home tab will give you the type of formatting in the number portion of the tab. Is it possible to color each cell that is formatted to different types such as text cells being blue and currency cells being green?
    Last edited by excel328; 07-20-2010 at 12:57 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Discerning Cell Formatting

    Is this a one-off exercise for spot checking or something more permanent ?

    You might consider using Styles or Conditional Format tests (see CELL function)

    For ex. if you applied the format of interest to say Cell A1 you could have a format rule on the other cells validating against that format.

    For sake of demo. assume B1:Z1 hold various values in various formats.

    You highlight B1:Z1 and apply a rule of:

    =CELL("format",B1)=CELL("format",$A$1)
    apply colour as desired

    You format A1 to say Currency and those Currency cells in B1:Z1 will be highlighted.

    Some fairly major notes however:

    -- using the CELL function route "Text" and "General" will appear to XL to be the same [G] - unclear if a major issue or not ?

    -- Decimal significance... if irrelevant use only the left char of the format code (ie C2 and C1 are the same - compare C only)

    -- Locale alterations ... CELL will return different results for Currency formatting pending client locale so this can preclude it's usage depending on scope.

    -- Altering cell formats is a non-volatile action (ie won't trigger a recalculation)

    VBA wise - if that's your preference, I'm not sure if there's a quick way to identify all cells simultaneously given you're concerned not with the data type of the underlying value(s) but with the explicit format applied to the cells themselves.
    I'm probably wrong though.
    Last edited by DonkeyOte; 07-19-2010 at 07:23 AM. Reason: typo(s)

  3. #3
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,445

    Re: Discerning Cell Formatting

    Hi,

    Something along these lines should do what you ask.

    Select the cells you require tested, and run this code.

    Please Login or Register  to view this content.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Discerning Cell Formatting

    you could use more func add in i think
    =XLM.GET.CELL(7,A1,TRUE)
    returns
    General or @ or 0.00 Or_-£* #,##0.00_-;-£* #,##0.00_-;_-£* "-"??_-;_-@_-
    not sure of the practicalities to use it in CF you need to make it a named formula tho
    Last edited by martindwilson; 07-19-2010 at 07:57 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Registered User
    Join Date
    07-15-2010
    Location
    California, United States
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Discerning Cell Formatting

    sweep's method works for me, but it is pretty computationally intensive on large ranges.

    DonkeyOte's method works well with one condition, but the problem with this is that it seems like the additional conditional formatting rules don't update properly after I have use more than one condition. When I have two conditions with conditional formating that I applied on the same range, cells formatting changes within the range does not cause proper color updates when the conditional formatted range is extended. Conditional formatting is also not performing the right type of formatting withing the original range.

    I have set currency formatting to green and text formatting to blue.
    I have currency formatting in a2 for cf condition and this is set for the green , when I change the cell format of a2 from currency to accounting the cf treats the currency and accounting as the same. Also it seems like fraction, time, long date, and general formatting is treated like text formatting for the text conditional formatting condition.
    Attached Files Attached Files

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Discerning Cell Formatting

    As outlined there are some fairly major limitations using the standard CELL function and as mentioned the VBA route would warrant a cell by cell iteration given the format rather than value takes precedence (at least AFAIK).

    Martin raises the point that the XLM GET.CELL call will return more info. but this is still in effect VBA though you can utilise via Names rather than via VBE (or via 3rd party add-in as advised).
    (note: XL2007 onwards use of XLM calls will necessitate file be saved as .xlsm)

    For ex. - using your sample file - with B1 the active cell you can create the following Defined Names:

    Please Login or Register  to view this content.
    With B1:G6 highlighted you can amend your rules to:

    Please Login or Register  to view this content.
    That said there are still some fairly major limitations to this approach - most notable of which is the fact that altering the explicit format of a cell is a non-volatile action.
    Until such time as a volatile action is performed (thereby invoking a calculation) it follows that the Conditional Formatting rules will not re-evaluate.

  7. #7
    Registered User
    Join Date
    07-15-2010
    Location
    California, United States
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Discerning Cell Formatting

    Thanks for the help. I will use all of these method in situations that seems fit.

+ 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