+ Reply to Thread
Results 1 to 7 of 7

Macro to Pickup a unique values in a column and sum up the value against it in all lines.

  1. #1
    Registered User
    Join Date
    07-12-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    4

    Question Macro to Pickup a unique values in a column and sum up the value against it in all lines.

    Dear Macro Gurus,

    I'm trying to explore some fixed length file and extract data based on certain key conditions. I managed to get the required information from the flat file. But now i need to group it and make another report out of it.!

    Here is my data,

    File Name Debit Amount Credit Amount
    CPUA0001.079 ----- 11412.38
    CPUA0001.076 ------ 1202.19
    CPUA0001.076 1202.19
    CPUA0001.076 1202.19
    CPUA0001.076 1202.19

    Now I need to group these against the file name and get the total debit and total Credit. Something like below in a seperate sheet.

    Unique Filename Total Debit amount Total Credit Amount.
    CPUA0001.079 XXXXX XXXXX
    CPUA0001.076 XXXXX XXXXX

    Please help me to achieve this! Thanks a lot.
    Do let me know if you require any other info

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro to Pickup a unique values in a column and sum up the value against it in all lin

    If your data is sorted (so all unique filenames are grouped together you can do something like:
    Please Login or Register  to view this content.
    You could also do this using formulas rather than vba with the sumif function.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to Pickup a unique values in a column and sum up the value against it in all lin

    You could also do this using formulas rather than vba with the sumif function AND PIVOT TABLE

  4. #4
    Registered User
    Join Date
    07-12-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro to Pickup a unique values in a column and sum up the value against it in all lin

    I think sum if can be used only if you need to calculate organised data, here the amount value is appearing in the multiple columns and in multiple rows, since a file can contain multiple credits and debits.
    I need to sum it based on a unique file.! its challenging for me!

  5. #5
    Registered User
    Join Date
    07-12-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro to Pickup a unique values in a column and sum up the value against it in all lin

    I'm not even able to group it with the unique values.
    Here i need to group / pull out the unique files and all its amount ( including credit and debit ) then I can sum up it easily.

  6. #6
    Registered User
    Join Date
    07-12-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro to Pickup a unique values in a column and sum up the value against it in all lin

    Quote Originally Posted by yudlugar View Post
    If your data is sorted (so all unique filenames are grouped together you can do something like:
    Please Login or Register  to view this content.
    You could also do this using formulas rather than vba with the sumif function.
    I'm not even able to group it with the unique values.
    Here i need to group / pull out the unique files and all its amount ( including credit and debit ) then I can sum up it easily.

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro to Pickup a unique values in a column and sum up the value against it in all lin

    Well you could either use sort before you run the macro or include the sort in the macro:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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