+ Reply to Thread
Results 1 to 8 of 8

Need to Sum data by Number Format Code

  1. #1
    Registered User
    Join Date
    11-03-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2010
    Posts
    9

    Need to Sum data by Number Format Code

    I have a column of data which has been entered as numbers and then formatted to show the relevant currency for that amount.
    e.g. [$AUD]#,##0.00 for Australian Dollars; [$EUR]#,##0.00 for Euro; etc.
    See the attachment.

    I need to determine the total amount for each currency.

    The approach I have thought of is to add a "currency" column and then calculate the totals with using the sumif function.

    My stumbling block is extracting the currency code from the formatting.
    Anyone have an idea on how I can do it with a formula - as I do not fancy having to do 1300 rows by hand!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Need to Sum data by Number Format Code

    You can't do this just using formula, because there isn't a formula to pick up another cell's number format.

    If you add this little bit of VB code to a module in your workbook:

    Please Login or Register  to view this content.
    You'll have a new worksheet function - SUMIFFORMAT

    I put the list of currencies in B2:B4 and then in C2 I put the formula:

    =SumIfFormat($A$2:$A$15,B2)

    And copied down to C4.

    Does that help you?

  3. #3
    Valued Forum Contributor
    Join Date
    04-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    547

    Re: Need to Sum data by Number Format Code

    Or, you can use a macro to write the currency codes into a new column:

    Please Login or Register  to view this content.
    Adjust ranges to suit.

    Then you can use a pivot table or the usual suspects (Sumif, Sumifs, etc) to aggregate the data.

    This macro only needs to run once and you don't have to save the file as a macro-enabled workbook after you've run it, since the values will now be stored in the cells.
    Like a post? Click the star below it!

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Need to Sum data by Number Format Code

    Surely it must be easier for you to use a seperate column with data validation lists allowing AUD, EUR, or USD?
    As it stands you have to change the formats for each individual entry, that must be tiresome!

    See this workbook
    1/. Specify the currency for each entry from the drop-downs in Column A

    2/. Select the currency to sum from the drop-downs in D2
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  5. #5
    Valued Forum Contributor
    Join Date
    04-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    547

    Re: Need to Sum data by Number Format Code

    Marcol, I may be wrong, but I read the question as the data being present with the format in place (obviously created by someone with too much time on their hands) and the predicament is not about formatting the numbers as a currency, but extracting the currency out of the already formatted numbers.

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Need to Sum data by Number Format Code

    @ npamcpp

    Your abolutely right, every cell has been manually formatted, and if changes are needed you have to reformat the cells.
    There's no pattern to the formatting!

    How awkward and error prone is that?

    Combine that with the fact that formulae can't detect formatting, then you'll see that this is a very convoluted way to do a very simple job.

  7. #7
    Valued Forum Contributor
    Join Date
    04-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    547

    Re: Need to Sum data by Number Format Code

    I agree. But maybe the asker is not in a position to change that. You know as well as I do that sometimes people get served with spreadsheets and need to run with what's there. So they come here for help.

    Lately, I feel that this forum is declining, though. Members are being stalked and personal details are being published without the member's consent. A certain moderator is on a power trip.

    A much safer and much more pleasant site for Office related questions is The Code Cage. Sign up and enjoy. Most ex-moderators of this forum are active there. And happy.

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Need to Sum data by Number Format Code

    Okay, maybe I missed the point ...

    Try this UDF
    In a Standard Module
    Please Login or Register  to view this content.
    Enter in B2, Drag/Fill Down as required.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    In the sheet module, this will format the result in D3
    Please Login or Register  to view this content.
    Select from the drop-down in D2
    Attached Files Attached Files

+ 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