+ Reply to Thread
Results 1 to 6 of 6

VBA to MATCH cells and Delete contents!

  1. #1
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    VBA to MATCH cells and Delete contents!

    Hi All,

    If it is not too much of an inconvenience to ask, would it be possible, if someone can asist me with the attached file.

    Basically, the file is an extract of a large database and contains 2 sheets.

    In Sheet 1, column A, there are 4 usernames: 'DAVBOR', 'KEIBRI', 'ALBCIL' and 'ANDGAL'. In sheet 1, these usernames will be unique.
    In Sheet 2, column A, there will be a whole column full of these usernames. In sheet 2, there can be more than one occurence of the same username.

    I would like to create a macro/VBA which would look in Sheet 2, Column A and:
    - find those usernames which are present in Sheet 2 but not in Sheet 1,
    - delete all those usernames- just found - from Sheet 2(i.e. delete those usernames found in Sheet 2 but not in Sheet 1)

    Apprciate a lot your kind help!


    Thanks a lot!

    Keibri
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: VBA to MATCH cells and Delete contents!

    Give this code a try
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to MATCH cells and Delete contents!

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    Re: VBA to MATCH cells and Delete contents!

    Cheers guys !!! Thanks a lot for your hep. tested both solutions!

    John, the only small issue I had, that when the VBA is run it will delete only the first occurrence. In the sense that if a username, which is not present in sheet 1, is repeated more than once in sheet 2, the macro will delete only the first occurrence. As for the rest, it worked great!! Thanks a lot for your help!

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to MATCH cells and Delete contents!

    You're welcome. Glad to help out and thanks for the feedback. Modified.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,769

    Re: VBA to MATCH cells and Delete contents!

    Really not needed as OP has got two working solutions but one could also use autofilter with array:

    Please Login or Register  to view this content.
    Alf
    Last edited by Alf; 11-23-2016 at 10:21 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. Delete only some of a cells contents
    By Dendrinos2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-11-2014, 06:16 AM
  2. Replies: 6
    Last Post: 12-07-2012, 05:38 PM
  3. [SOLVED] Delete contents of blank cells
    By freud1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-30-2012, 10:53 AM
  4. Delete Contents of Cells with 0
    By EJensen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-04-2009, 05:10 PM
  5. Delete contents of cells
    By mikespeck in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-27-2006, 10:25 AM
  6. [SOLVED] Delete Contents of Cells
    By ir26121973 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-05-2006, 02:15 PM
  7. Delete specific cells contents in a row with some locked cells in the same row
    By trussman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2005, 03:06 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