+ Reply to Thread
Results 1 to 4 of 4

Extracting entire row to new sheet based on criteria, and then deleting empty row

  1. #1
    Registered User
    Join Date
    11-20-2013
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question Extracting entire row to new sheet based on criteria, and then deleting empty row

    Dear All,

    I am a new user to this forum (and also new to using visual basics), but did recently find a partial solution to my issue in the following link: http://www.excelforum.com/excel-form...-criteria.html

    Here is my question.... I am setting up an excel file to use as a task list. I've got it to a point where I have an IF statement and conditional formatting set up so that when you place an "x" in column D it changes the font in the entire row to strikethrough the text. I then have a macro set to a button on my toolbar to clear all "x"-ed rows and move them from the worksheet labeled OPEN to another worksheet in the same workbook labeled CLOSED. The macro works; however I would like to add code to delete the empty rows in the OPEN worksheet after they are moved, and I'm not sure how to do that.

    The code I am currently using is as follows (modified just a bit from the one found in the link to another thread that I provided above). Can anyone help me? Thank you!

    Sub copyPaste()
    Dim ws As Worksheet
    Dim wt As Worksheet
    Set ws = Sheets("Open")
    Set wt = Sheets("Closed")
    Dim i As Long
    Dim lr As Long
    lr = ws.Range("i" & Rows.Count).End(xlUp).Row
    Dim lt As Long

    For i = 1 To lr
    lt = wt.Range("A" & Rows.Count).End(xlUp).Row
    If ws.Range("i" & i) = "Closed" Then
    ws.Range("i" & i).EntireRow.Cut wt.Range("A" & lt + 1)
    End If
    Next i
    End Sub

    PS - - I am only at work for another 10 minutes, so I will answer any return posts tomorrow morning. Thanks again to anyone that can help!!

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

    Re: Extracting entire row to new sheet based on criteria, and then deleting empty row

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-20-2013
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Extracting entire row to new sheet based on criteria, and then deleting empty row

    Thanks for the quick reply John! I will check it out right away tomorrow morning. Have a good evening!

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,833

    Re: Extracting entire row to new sheet based on criteria, and then deleting empty row

    Another approach. Place this macro in the worksheet code module. Right click the tab for the worksheet "Open" and click 'View Code'. Copy and paste the macro into the empty code window that opens up.. Close the code window to return to your sheet. As soon as you enter "Closed" in column I and exit the cell, the corresponding row will automatically be copied sheet "Closed" and deleted from sheet "Open".
    Please Login or Register  to view this content.

+ 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. Extracting entire row to new sheet based on criteria
    By yukkiwong in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 04-16-2015, 05:59 AM
  2. Copy entire row from Master sheet based on two criteria
    By melispol44 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-06-2013, 08:07 PM
  3. How to copy an entire row from one sheet to another based on criteria
    By Mian USman in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-12-2013, 04:17 AM
  4. Deleting Entire Row Based on Criteria in single cell
    By CBG05QB in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-08-2011, 08:40 AM
  5. [SOLVED] Copy entire row to another sheet based on a criteria
    By Brig Siton in forum Excel General
    Replies: 3
    Last Post: 08-07-2006, 04:05 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