+ Reply to Thread
Results 1 to 7 of 7

Move entire row to new worksheet based on specific value

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    Utica, NY
    MS-Off Ver
    Excel 2010
    Posts
    4

    Move entire row to new worksheet based on specific value

    Hi all...I am new to the forum and I have a problem that is almost identical to a post that is in this forum from Sept of 2011...but, while the concept is almost identical, I cannot manipulate the code to work for me. I have a product backlog worksheet. Each row contains a product problem. When the value in the Status column (Column D) is equal to 'Done', the user would like to click a button and move all rows with that status to an 'Archive' sheet and then be deleted from the current product backlog sheet. When the rows are added to the archive sheet, the user would like them to be automatically placed on the next open row.

    The user is sorting the Status column so all rows with a status = 'Done' are all together.

    Another problem is I can't seem to save the macro in the worksheet (I use Excel 2010).

    I've included a sample spreadsheet....the code below is what I tried to modify but to no avail....

    Thanks for any help that you can give....

    Private Sub Worksheet_Change(ByVal Target As Range)
    ' Code goes in the Worksheet specific module
    Dim rng As Range
    Dim i As Long
    ' Set Target Range, i.e. Range("A1, B2, C3"), or Range("A1:B3")
    Set rng = Target.Parent.Range("D:D")
    ' Only look at single cell changes
    If Target.Count > 1 Then Exit Sub
    ' Only look at that range
    If Intersect(Target, rng) Is Nothing Then Exit Sub
    ' Action if Condition(s) are met (do your thing here...)
    If LCase(Target.Value) = "completed" Then
    i = Target.Row
    Target.EntireRow.Cut Sheets("Sheet3").Cells(Rows.Count, "A").End(xlUp).Offset(1)
    Cells(i, "D").EntireRow.Delete
    End If
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move entire row to new worksheet based on specific value

    Please use code tags with your code as per forum's rule.
    This does the first part of your question.

    Please Login or Register  to view this content.
    Last edited by AB33; 08-06-2013 at 05:08 PM.

  3. #3
    Registered User
    Join Date
    07-24-2013
    Location
    Utica, NY
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Move entire row to new worksheet based on specific value

    Thanks very much for input and I apologize for mistake with code...appreciate quick reply. I will try this today...

  4. #4
    Registered User
    Join Date
    07-24-2013
    Location
    Utica, NY
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Move entire row to new worksheet based on specific value

    Thanks AB33...the code works perfectly! I now realize the code I included uses the Worksheet_Change Event thinking the user would like it that the macro would execute every time a cell in Column D in its sheet is changed.

    But, what if the user would rather not have the row moved and deleted everytime the cell in Column D is changed to 'Done' but rather wait and click a button when the value is equal to 'Done'? So,upon clicking that button, all rows with Status = 'Done' would be moved to an 'Archive' sheet and then deleted from the current product backlog sheet. And like with the code you provided, when the rows are added to the archive sheet, the user would like them to be automatically placed on the next open row?

    Thanks again for your help....

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Move entire row to new worksheet based on specific value

    Try the attached.
    This is not an event-driven code. It will not run auto, but you need to run it.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-24-2013
    Location
    Utica, NY
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Move entire row to new worksheet based on specific value

    Thank you AB33!! This seems to do the trick...I attached your macro to a command button and it works like a charm....Being a novice at VBA, I never would have been able to achieve this...thanks again!

  7. #7
    Registered User
    Join Date
    12-16-2014
    Location
    Massachusetts
    MS-Off Ver
    2013
    Posts
    1

    Re: Move entire row to new worksheet based on specific value

    Hello,

    I am trying to do the same thing as D0lph1n - I copied the code however I am getting a runtime error for the line
    With Sheets ("name of sheet")

    Any ideas what that might be?

+ 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. [SOLVED] Move entire row to another worksheet based on cell value
    By bdf0827 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 04-09-2014, 07:01 AM
  2. Macro - Move entire row to other tab based on specific criteria
    By thomasp in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-08-2013, 11:29 AM
  3. [SOLVED] Move entire row to another worksheet based on cell value
    By jesseg005 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-03-2013, 12:52 PM
  4. [SOLVED] move entire row to another worksheet based on cell value
    By Berndene in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-14-2012, 10:13 AM
  5. [SOLVED] Move entire row to another worksheet based on cell value
    By mmctague in forum Excel General
    Replies: 11
    Last Post: 06-26-2012, 12:43 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