Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Extracting currency from format (Excel 2002)

    I've received a spreadsheet from a friend and it contains a format field for all the differant currencies. Are there a way of extracting the format of this field example, the format is #,##0.00_-" GHC";#,##0.00-" GHC";"" and I would like to extract the GHC.

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Extracting currency from format (Excel 2002)

    This might be difficult, since some formats are stored as a literal string, others are coded. There are many currencies using $ for instance, and Excel keeps track of which one is used; US$, for instance, is [$$-409]. No quotes are used around a code such as that one. But if all currency cells follow the pattern of your example, you could use this custom function:

    Function GetCurrency(aCell As Range)
    Dim strResult As String
    Dim intPos1 As Integer, intPos2 As Integer
    strResult = aCell.NumberFormatLocal
    intPos1 = InStr(strResult, Chr(34))
    intPos2 = InStr(intPos1 + 1, strResult, Chr(34))
    strResult = Mid(strResult, intPos1 + 1, intPos2 - intPos1 - 1)
    GetCurrency = Trim(strResult)
    End Function

    Example of use: cell A1 is formatted as in your example. In cell B1, enter the formula
    =GetCurrency(A1)
    Cell B1 will display GHC.

    The function will NOT work correctly for cells formatted with $ or

  3. #3
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Extracting currency from format (Excel 2002)

    Thanks Hans it works like magic

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •