Get name of cell format using VBA RRS feed

  • Question

  • I want to know the type of formatting used in a cell.

    I am aware that I can retrieve the cell format using Range.NumberFormat property. But, I could not find syntax to extract the formatting type (or category)

    For example, if cell has value 0.95 and is formatted as percentage, it will be displayed as 95%. And using the number format property on the cell shows that format is '0%'. Is there any way to extract the type i.e. in this case 'Percent'?

    NOTE: Excel has predefined named formats such as General, Number, Currency, Percent, Text, etc.

    Wednesday, May 15, 2019 5:26 AM

All replies

  • Karthik,
    Re: names for NumberFormats in Excel

    There are no "names" available for number formats in Excel that I am aware of.
    (i've been around excel & vba for awhile)
    The Format function does have some named arguments, but that is a different animal.

    Also, since a custom number format has 4 parts (plus, minus, zero, text),
    it's possible to have four different number formats for a single cell.
    That would be difficult to name (mixed?)

    Custom_Functions add-in (19 new functions)
    Download from MediaFire...

    Wednesday, May 15, 2019 6:57 PM
  • Thanks.

    Just to confirm, you are not aware of any property that can tell if a cell format is number, currency or percent?

    Thursday, May 16, 2019 4:11 AM
  • Karthik,
    re:  identify name of number format

    You could compile a list of typical formats for the categories and then run
    some sort of fuzzy matching comparison against the actual number format.
    I doubt if it would work very well.

    Again, I don't know of any naming capability.
    Thursday, May 16, 2019 5:18 AM