+ Reply to Thread
Results 1 to 15 of 15

Cut and Paste Rows from one worksheet to another based on criteria in two columns

Hybrid View

  1. #1
    Registered User
    Join Date
    02-08-2013
    Location
    St Petersburg, FL
    MS-Off Ver
    Excel 2010
    Posts
    19

    Cut and Paste Rows from one worksheet to another based on criteria in two columns

    I’ve found a number of posts on this subject but can’t seem to find one that quite works for me.
    I have a workbook with two worksheets.( Started, Completed) In worksheet “Started” if column F has any data (anything other than blank) and column H contains anything other than “Transfer Accepted”,
    I need to cut and paste these rows into worksheet “Completed” and delete the empty row in “Started”.
    (the data in the two columns may not coincide to meet the criteria)

    Thanks for any help!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    Hi.

    Try this:

    Transfer.xlsm
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Registered User
    Join Date
    02-08-2013
    Location
    St Petersburg, FL
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    Quote Originally Posted by jraj1106 View Post
    Hi.

    Try this:

    Attachment 213054
    Thanks, works great for half of it. I also need to move column H if it contains anything other than “Transfer Accepted”,

    Thanks for the help!

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

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    Sub CombineAllSheets()
    
     Dim ms As Worksheet, LRms As Long, sh As Worksheet, LR As Long, i As Long
     
        Application.ScreenUpdating = 0
        Application.DisplayAlerts = 0
        
        On Error Resume Next
        
        Set ms = Sheets("Completed")
      
        With Sheets("Started")
                LR = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
                
            For i = 2 To LR
               
                 If Trim(.Cells(i, "F").Value) <> vbNullString Then
                    If Trim(.Cells(i, "H").Value) <> "Transfer Accepted" Then
                    .Rows(i).Cut ms.Cells(Rows.Count, 1).End(xlUp).Offset(1)
                    End If
                 End If
            Next i
                 
        End With
          
         Application.CutCopyMode = 0
         
         Application.ScreenUpdating = 1
        
         Application.DisplayAlerts = 1
    End Sub

  5. #5
    Registered User
    Join Date
    02-08-2013
    Location
    St Petersburg, FL
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    Thanks AB33 and jraj1106. I've tried all the codes including the last from J. But Column H is still Not moving. I've attached my results
    Attached Files Attached Files

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

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    "In worksheet “Started” if column F has any data (anything other than blank)"


    On the attached, column F is blank, so the code will not find any non blank Column F.
    Are the condition both, or one of them, because the code will be different if it is the latter
    Last edited by AB33; 02-08-2013 at 10:38 AM.

  7. #7
    Registered User
    Join Date
    02-08-2013
    Location
    St Petersburg, FL
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    Correct. These are the resluts from the code I have tried. Column H however still contains data other than "transfer accepted"

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

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    Are these criteria,
    Column F is not blank NOT column H is not "transfer accepted"
    or
    Column F is not blank OR column H is not "transfer accepted" ?
    The code for both is not the same. Please clarifay

  9. #9
    Registered User
    Join Date
    02-08-2013
    Location
    St Petersburg, FL
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    Column F is not" blank" AND column H is not "transfer accepted"

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

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    Well, I do not see what is wrong with the code I provided then? For e.g in Rows 2, 4 and 6, Column F is not blank(Has value-letters) and column H is not "Transfer Accepted", so these rows will move over.

  11. #11
    Registered User
    Join Date
    02-08-2013
    Location
    St Petersburg, FL
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    Thanks for your time. I apologize if I am not explaining this properly. I attached a workbook with your code. These are the results I'm getting after I run the code. Column H still has data other than "Transfer Accepted"
    Attached Files Attached Files

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

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    Please see attached.
    I have two codes with two different results. I suspect, your request was code 2 which is OR, not NOT. Let me know
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    02-08-2013
    Location
    St Petersburg, FL
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    Perfect! Thank you so much for your time and patients.

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

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    You are welcome!
    Please close this thread now as solved. Go in to the top right-hand side of the page, choose "Thread Tools" ,select solved from the drop down menu

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

    Re: Cut and Paste Rows from one worksheet to another based on criteria in two columns

    You are welcome!
    Please close this thread now as solved. Go in to the top right-hand side of the page, choose "Thread Tools" ,select solved from the drop down menu

+ 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.6.0 RC 1