+ Reply to Thread
Results 1 to 4 of 4

Looking VBA code/formulas to find the sum of certain range with specific criteria

  1. #1
    Registered User
    Join Date
    09-11-2020
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    17

    Smile Looking VBA code/formulas to find the sum of certain range with specific criteria

    Hello everyone,

    Column A contains the the name of package name, column B contains document number and Column C contains the size of each document. What I seek is the sum of document size for those documents which belongs to the same package. If you click the dropdown arrow for column A (package name), there are 16 unique package names. For instance, for package name 30KBB_CSSS_0CBE.TSE3, there are 791 documents and i want to have the sum of document sizes for those 791 documents. Since there are altogether 16 unique package names, i am looking for better/faster way to find the sum of document sizes for documents of those 16 packages.
    If I filter on each package and find the sum of documents for that package, then I have to do it 16 times ( in some case more than 100 times) and its going to consume lot of time. So is there any smarter and faster way?

    Please find the enclosed file.

    Thank you in advance. ☺
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Looking VBA code/formulas to find the sum of certain range with specific criteria

    Formula for D2 and then Fill Down

    =SUMIF(B:B,B3,C:C)


    Or to achieve the same without Duplicates

    =IF(COUNTIF(B$1:B2,B2)=1,SUMIF(B:B,B3,C:C),"")
    Last edited by mehmetcik; 10-30-2020 at 09:25 AM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Looking VBA code/formulas to find the sum of certain range with specific criteria

    See attached which uses a pivot table approach

    There are some document sizes that have #N/A in column C hence the PT can't evaluate those. You'll need to ensure they are either blank or zero.
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    09-11-2020
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    17

    Re: Looking VBA code/formulas to find the sum of certain range with specific criteria

    Hello,
    Thank you for your help.
    Last edited by susanstha; 11-04-2020 at 06:17 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] code find last cell in a specific column in specific worksheet and paste value
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-14-2017, 10:38 AM
  2. [SOLVED] Inserting formulas and html code based on specific cell range criteria
    By JohnnyBoyxxx in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-08-2015, 01:23 PM
  3. For EACH cell in specific range meeting specific criteria, call a sub
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-02-2014, 03:00 PM
  4. [SOLVED] Several formulas with specific range criteria (AVERAGEIFS, STDEV(IF), COUNTIFS)
    By thaphthia in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 04-11-2013, 05:22 PM
  5. Code to find named range doesn't find the correct field range?
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-12-2012, 05:54 PM
  6. Replies: 4
    Last Post: 09-18-2012, 10:54 AM
  7. code to add formulas to a range with previous formulas appearing inside the new one
    By Excel-o-ratoR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2010, 06:02 AM

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