+ Reply to Thread
Results 1 to 11 of 11

VBA Copy items being added/deleted to new sheet before deletion

  1. #1
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    VBA Copy items being added/deleted to new sheet before deletion

    xladept (awesome member) wrote this for me quite awhile ago and it has been put to great use for the past few years.

    The script basically combines two sheets (it compares them by column A, if they exist in both they are left. If they are in one or the other it either adds or deletes them from the main sheet).
    End of my macro it pops up saying how many were deleted and how many were added.

    I'd like to have in the popup where it says which customers were deleted or maybe pastes them to a new sheet before deleting (probably better to have them pasted on another sheet)

    The main combine macro is here
    Please Login or Register  to view this content.
    Later in my macro this shows how many were added or deleted
    Please Login or Register  to view this content.

    So the part in the first where it is deleting - that's the part I would like it to store or write out which ones were added or deleted. I really only need it to tell me the value from column A that was deleted (that's the customer number).

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VBA Copy items being added/deleted to new sheet before deletion

    Hi NewYears1978,

    Without a file, it is untested but try below code whereas I have highlighted added lines in red
    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  3. #3
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: VBA Copy items being added/deleted to new sheet before deletion

    I will try that out, sorry for not having a sample to create a fake version of this file would be difficult.

    Edit://

    Okay got some errors, tried to work through them to no avail.

    I am attaching two sheets. The way the macro works is you hit the UPDATE button (or run the macro CombineAll then when it asks for file choose the "data" file.
    Attached Files Attached Files
    Last edited by NewYears1978; 09-07-2021 at 05:03 PM.

  4. #4
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: VBA Copy items being added/deleted to new sheet before deletion

    I tried to define Ws that you added since it wasn't defined but that just caused another error =D

  5. #5
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VBA Copy items being added/deleted to new sheet before deletion

    Oops, my bad I am used to use variable ws for WorkSheet .. It should be wc not ws
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: VBA Copy items being added/deleted to new sheet before deletion

    I think I tried that and got a different error, trying again =D

    Edit: Okay no errors however no new sheet was added. Hmmm
    Last edited by NewYears1978; 09-09-2021 at 04:12 PM.

  7. #7
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VBA Copy items being added/deleted to new sheet before deletion

    Then it means no rows were deleted from wc sheet. When the IF condition highlighted in blue is met, below line will save the value of column A before deleting the line

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: VBA Copy items being added/deleted to new sheet before deletion

    I set my example up specifically for that, so that one row was deleted, but it didn't make a new sheet...hrmmm.

  9. #9
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VBA Copy items being added/deleted to new sheet before deletion

    I am sorry I just noticed something wrong in my code, try to change the below line
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: VBA Copy items being added/deleted to new sheet before deletion

    WORKS. Thank you so much for the help. This will make a few of my coworkers very happy =D

  11. #11
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VBA Copy items being added/deleted to new sheet before deletion

    Glad to help

    If that takes care of your question, please take a moment & mark this thread as [SOLVED] from the Thread Tools above your first post

+ 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. Replies: 4
    Last Post: 01-22-2021, 10:09 PM
  2. update target sheet with rows as they are added or deleted to master sheet
    By RLR31064 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-20-2014, 05:41 PM
  3. Prevent workbook deletion or create the copy upon the deletion?
    By ciapul12 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-29-2014, 04:35 PM
  4. Move recently added items to another sheet and add to bottom of list.
    By thequiff in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-07-2012, 07:04 AM
  5. [SOLVED] Paste Special Won't Work After Deletion Step Added
    By One-Eyed Enos in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2012, 12:40 PM
  6. Replies: 8
    Last Post: 02-27-2009, 07:38 AM
  7. Replies: 1
    Last Post: 06-24-2005, 12:21 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