+ Reply to Thread
Results 1 to 4 of 4

Delete cell and adjacent column if the same data is found is found in another column

  1. #1
    Registered User
    Join Date
    06-07-2012
    Location
    US
    MS-Off Ver
    Excel Office 365
    Posts
    56

    Delete cell and adjacent column if the same data is found is found in another column

    I have a macro that creates a pivot table and then copies the output over to a new worksheet. Problem is the row data that I copied over has additional unwanted entries. Can a macro or VBA look at the new column of data and see if it matches a list of data in another column. Then if it does, remove the the data in column 1 with it's adjacent cell and then shift everything up? I attached a sample of something that looks like what I have.example1.xlsx

  2. #2
    Registered User
    Join Date
    06-18-2012
    Location
    Devon, England
    MS-Off Ver
    Excel 2003 & Excel 2010
    Posts
    10

    Re: Delete cell and adjacent column if the same data is found is found in another column

    Hi Nguerra,

    The code below creates a reference column (C) to mark whether the data item appears in the pre-existing list, and deletes these. It then clears the contents of the reference column.

    Limitations = I have sorted the data by the reference column, so this may need to be resorted following this process to an order that suits you.

    I hope it helps!

    KimberleyBob


    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-07-2012
    Location
    US
    MS-Off Ver
    Excel Office 365
    Posts
    56

    Re: Delete cell and adjacent column if the same data is found is found in another column

    Thank you KimberleyBob, Your macro works great on the file I posted but I'm having trouble adding it to my larger file. by adding comments, I can see where you added the C column with 0s' and 1's. After this step is completed however I'm running into issues. It looks like the delete and shift up is modifying my existing data throughout the worksheet. Is it possible to just look and see if the value in the C column is either a 0 or a 1 and if a 1, only delete cells Ax, Bx, Cx, and then shift up columns A,B, and C without affecting the rest of the worksheet?

  4. #4
    Registered User
    Join Date
    06-18-2012
    Location
    Devon, England
    MS-Off Ver
    Excel 2003 & Excel 2010
    Posts
    10

    Re: Delete cell and adjacent column if the same data is found is found in another column

    It only currently deletes the cells in columns A&B - however it may be the sort function which is causing some problems.

    Try this one instead - I've asked the data to sort only columns A:C, rather than the whole sheet (based on C):

    Please Login or Register  to view this content.
    I also added some comments so that you can see what each step is doing.

+ 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. Check for values in a table and if found add value found in column to left to list
    By robhargreaves in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-07-2013, 02:57 PM
  2. [SOLVED] If value found in column, then adjacent cell in value's row...
    By frankly75 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-17-2013, 12:51 PM
  3. [SOLVED] Comparing Two Columns and Copy Adjacent Column IF Match Found
    By 10AVATAR in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 09-29-2012, 04:33 PM
  4. Delete row if value in column C found
    By guvner5 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-13-2012, 05:55 AM
  5. Delete row when empty cell found in column
    By jillstone69 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-14-2010, 12:28 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