+ Reply to Thread
Results 1 to 6 of 6

VBA to find identic cells and count the sum between corespondent cells

  1. #1
    Forum Contributor
    Join Date
    10-06-2017
    Location
    Europe
    MS-Off Ver
    2013
    Posts
    123

    Talking VBA to find identic cells and count the sum between corespondent cells

    Hello all,

    I need some help with the attached file - my boss is trying to kill me, i think.

    On "sheet1" column U, i have some codes. I need the VBA that can find (for example) all cells that contains "891" on column U, make the sum between corespondent cells in column P, and paste the result on "sheet2" B7. (in this example, 97791 should be pasted on sheet2, cell B7)
    After this, the code must find all cells containing another code (for example 159), make the sum between corespondent cells in column P, and paste the result on "sheet2" B3.

    And so on, for all the codes in column U.


    Any help would be hightly appreciated.

    Thank you in advance.
    Attached Files Attached Files

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: VBA to find identic cells and count the sum between corespondent cells

    Frankly speaking, this attachment is useless. It contains simply no data at all.

    From the description, it seems that you can easily achieve the result by simple Pivot Table - have you tried/considered it?

    If some very specific sequence of codes is needed (although in attachment they are sorted ascending, which can be easily done with pivot table), you may either use custom sort or use some lookup function to retrieve sums from pivot table created somewhere else in the workbook.
    Best Regards,

    Kaper

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: VBA to find identic cells and count the sum between corespondent cells

    Hi lofgren,

    No need for VBA - Excel's SUMIF function will do the job. Put this formula in cell B3 of Sheet2...

    =SUMIF(Sheet1!U:U,A3,Sheet1!P:P)

    ...and copy down to cell B7.

    Native Excel formulas are always the preferred over VBA.

    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: VBA to find identic cells and count the sum between corespondent cells

    Give this a whirl.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Forum Contributor
    Join Date
    10-06-2017
    Location
    Europe
    MS-Off Ver
    2013
    Posts
    123

    Re: VBA to find identic cells and count the sum between corespondent cells

    Thank you so much for your answer, bakerman2 It's almost perfect.
    Could you please tell what should i change in order to leave a free column between the the results?

    Thank you Trebor76 & Kaper

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: VBA to find identic cells and count the sum between corespondent cells

    Here you go.
    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)

Similar Threads

  1. [SOLVED] Count the cells in a string of cells omitting zeros and specific cells
    By Hawkmoth1 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-23-2017, 08:39 AM
  2. Find/Count in Multiple Cells
    By ptmuldoon in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 10-12-2016, 01:47 PM
  3. Find count of filled cells and empty cells in a column
    By thepinkgeologist in forum Excel General
    Replies: 4
    Last Post: 09-22-2015, 01:03 PM
  4. Find and count specific numbers in a range of cells
    By aslante in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-06-2015, 04:35 AM
  5. Replies: 4
    Last Post: 02-11-2015, 09:02 AM
  6. [SOLVED] Find Merge cells Count
    By mohan.r1980 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-25-2013, 06:29 AM
  7. Replies: 2
    Last Post: 06-24-2010, 04:53 PM

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