+ Reply to Thread
Results 1 to 7 of 7

Macro to Subtract values where Ref is the same and then delete Duplicate Ref

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,873

    Macro to Subtract values where Ref is the same and then delete Duplicate Ref

    I have data on sheet "Extracted data" where the Ref is in Col A and the Value is in Col B


    I would like VBA code to do the following


    1) Where The Ref in Col A is the same, then the values for the references that are the same are to be subtracted from those references that are the same and the net result to be inserted in the first ref that is the same for eg Ref 115 value 549.75 in Say A5 and Ref 115 value 549.35 in A8 . The net result is 0.40 and must go into cell A5
    2) Once the above has been done, then the second duplicate reference must be deleted


    I have attached sample data and manually did steps 1 and 2 above and have shown the results on sheet "Final Result"

    It would be appreciated if someone could assist me

  2. #2
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Macro to Subtract values where Ref is the same and then delete Duplicate Ref

    Within the extracted data tab, the difference between the two sets of common reference numbers is zero, yet the difference in the Final result tab shows .01. If the difference is zero should it always be .01?

  3. #3
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,873

    Re: Macro to Subtract values where Ref is the same and then delete Duplicate Ref

    My Apologies

    I have updated my sample data, which I have attached

  4. #4
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Macro to Subtract values where Ref is the same and then delete Duplicate Ref

    Try

    Please Login or Register  to view this content.
    Last edited by maniacb; 07-06-2021 at 12:02 AM. Reason: Updated code to delete from the bottom up

  5. #5
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,873

    Re: Macro to Subtract values where Ref is the same and then delete Duplicate Ref

    Thanks for the help, maniacb

    Your code worked on the sample uploaded in Post # 1


    However, It does not work on this sample data uploaded. I have also shown what the result should look like on sheet "Final result"


    Kindly test & amend your code

  6. #6
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Macro to Subtract values where Ref is the same and then delete Duplicate Ref

    Post #4 code has been updated. My bad.

  7. #7
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,873

    Re: Macro to Subtract values where Ref is the same and then delete Duplicate Ref

    Many Thanks for the help.


    Code works perfectly

+ 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. Add values from duplicate rows and delete duplicate
    By jane204 in forum Excel General
    Replies: 3
    Last Post: 11-20-2016, 08:36 AM
  2. Macros to delete entire duplicate row for duplicate values
    By cutelebel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2014, 12:09 PM
  3. Delete duplicate values from cells containing multiple values
    By Buzzed Aldrin in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-03-2014, 02:50 PM
  4. add, delete, update and add and subtract stock values..
    By djmag in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-12-2013, 07:38 AM
  5. VBA helps needed to Sum duplicate values and delete duplicate rows
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-03-2013, 11:40 PM
  6. [SOLVED] Sum Duplicate values then delete duplicate rows
    By keekdapolak in forum Excel General
    Replies: 7
    Last Post: 09-20-2012, 02:57 PM
  7. Need Macro to delete duplicate Values in Column
    By floridagunner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-19-2007, 11:45 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