+ Reply to Thread
Results 1 to 4 of 4

Thread: Macro to move row to another sheet and delete

  1. #1
    Registered User
    Join Date
    01-18-2010
    Location
    California, US
    MS-Off Ver
    Excel 2003
    Posts
    48

    Macro to move row to another sheet and delete

    Hey everyone,
    I've been using the following code:

    Private Sub Worksheet_Change(ByVal Target As Range)
     If Target.Column = 17 Then
      If Target = "YES" Then
        Application.EnableEvents = False
          nxtRow = Sheets("Closed Orders").Range("Q" & Rows.Count).End(xlUp).Row + 1
           Target.EntireRow.Copy _
            Destination:=Sheets("Closed Orders").Range("A" & nxtRow)
           Target.EntireRow.Delete
      End If
     End If
     Application.EnableEvents = True
    End Sub

    This works great but it relocates the entire row across all exisiting cells. I only need to relocate a certain range of columns along that row. Can the code posted above be rewritten to specify that range? Let me know if attaching a dummy workbook would explain better. Thank you all in advance for your help.
    Attached Files Attached Files
    Last edited by livinglegend629; 01-17-2012 at 02:08 PM.

  2. #2
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,382

    Re: Macro to move row to another sheet and delete

    Yes, please attach your dummy file.
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    01-18-2010
    Location
    California, US
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: Macro to move row to another sheet and delete

    Thanks for loooking arlu.

    Dummy book added. The code i have above relocates entire row if column Q is marked YES, but it moves the entire row, I'm looking to just move everything that is in the yellow and green areas.

  4. #4
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,382

    Re: Macro to move row to another sheet and delete

    Use this -
     
    Private Sub Worksheet_Change(ByVal Target As Range)
     If Target.Column = 17 Then
      If Target = "YES" Then
        Application.EnableEvents = False
          nxtRow = Sheets("Closed Orders").Range("Q" & Rows.Count).End(xlUp).Row + 1
           range("C" & target.row & ":V" & target.row).Copy _
            Destination:=Sheets("Closed Orders").Range("A" & nxtRow)
           range("C" & target.row & ":V" & target.row).Delete
      End If
     End If
     Application.EnableEvents = True
    End Sub
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0