+ Reply to Thread
Results 1 to 8 of 8

Delete rows on 2 different worksheets based on cell value from one worksheet

  1. #1
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    191

    Delete rows on 2 different worksheets based on cell value from one worksheet

    Hi,

    Using VBA, I need to look at each row on worksheet2 and if the values of column O + Column P in a given row is zero, delete that entire row from worksheet 2, and at the same time delete the same row from worksheet1.

    Please could someone suggest example code to achieve this.

    Many thanks,

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Delete rows on 2 different worksheets based on cell value from one worksheet

    Maybe this

    Please Login or Register  to view this content.
    Martin

  3. #3
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    191

    Re: Delete rows on 2 different worksheets based on cell value from one worksheet

    Hi,

    Thanks for that, I can't seem to get it to work though, it is deleting every row. Not just rows with value of zero in those 2 columns.

    Any suggestions?

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Delete rows on 2 different worksheets based on cell value from one worksheet

    Can you post the sheet that you are working on - maybe some of my assumptions about it are incorrect.

  5. #5
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    191

    Re: Delete rows on 2 different worksheets based on cell value from one worksheet

    Of course, I have attached an example of the layout, there are far more rows than this in the real thing.

    I want to delete the entire row if the customer has no sales at all, so showing zero in both column O & P on the 2014 sheet. When a row is deleted from the 2014 sheet, the same row must also be deleted from the 2013 sheet.

    Thanks,
    Attached Files Attached Files

  6. #6
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Delete rows on 2 different worksheets based on cell value from one worksheet

    Please Login or Register  to view this content.
    Can't see why it was deleting all the rows (it didn't for me). Modification above does not touch the block of data below the first block in the 2014 sheet. Paste into Module1.

  7. #7
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    191

    Re: Delete rows on 2 different worksheets based on cell value from one worksheet

    Sorry I still can't get it to work. After everything else I have done with this I am surprised to be having so much trouble with a simple thing like this.

    It deletes every row even though only a few of them show zero in both column O & P.

    I am completely baffled by this.

  8. #8
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    191

    Re: Delete rows on 2 different worksheets based on cell value from one worksheet

    At last I figured it out....

    I was inserting this into a section of code where I had changed xlcaculation to manual, the figures had just been pasted onto the worksheet and so the values of the total columns were not manually calculating themselves.

    I fixed it by adding this line in just above....

    Please Login or Register  to view this content.
    Anyway, many thanks for your help.

+ 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 Row based on cell value through multiple worksheets
    By jgrant1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-08-2012, 03:19 PM
  2. [SOLVED] Delete Rows Based on Data in Separate Worksheet
    By Smitty7 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-27-2012, 05:48 PM
  3. Delete rows based on values from worksheet
    By dc6463 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-29-2008, 10:16 AM
  4. How to loop through worksheet and delete rows based on criteria
    By rgrogan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-20-2007, 05: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