Results 1 to 7 of 7

Moving rows to a different worksheet based on multiple criteria

Threaded View

  1. #1
    Registered User
    Join Date
    03-01-2016
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    47

    Moving rows to a different worksheet based on multiple criteria

    Hi all,

    I am using the following code to move rows from my worksheet if the cell in column K = Complete.

    I need to also move rows if the cell in column K = Cancelled. The following is the code I am using. I'm not great with VBA yet so i am having a problem adding the 2nd criteria of cancelled. Can anyone tell me how to amend my code to include Cancelled as a critreria?

    Sub CopyRequests()
    
    Worksheets("SOR Requests").Unprotect Password:="DC2"
    Worksheets("Completed SOR's").Unprotect Password:="DC2"
    
        Dim xRg As Range
        Dim xCell As Range
        Dim I As Long
        Dim J As Long
        Dim lngR As Long
        
        I = Worksheets("SOR Requests").UsedRange.Rows.Count
        J = Worksheets("Completed SOR's").UsedRange.Rows.Count
        
        If J = 1 Then
            If Application.WorksheetFunction.CountA(Worksheets("Completed SOR's").UsedRange) = 0 Then J = 0
        End If
        
        Application.ScreenUpdating = False
        
        For lngR = I To 10 Step -1
            If Application.CountIf(Worksheets("SOR Requests").Rows(lngR), "Complete") > 0 Then
                    With Worksheets("SOR Requests").Rows(lngR)
                    Worksheets("Completed SOR's").Rows(J + 1).Value = .Value
                    .Delete
                End With
                J = J + 1
            End If
        Next lngR
        
         
        Application.ScreenUpdating = True
        
        Range("B10:B200").Formula = "=IF(A10="""","""",WORKDAY(A10,9,Holidays!$A$1:$A$8))"
        Range("C10:C200").Formula = "=IF(A10="""","""",NETWORKDAYS($A$1,B10,Holidays!$A$1:$A$8))"
        
    Worksheets("SOR Requests").Protect Password:="DC2"
    Worksheets("Completed SOR's").Protect Password:="DC2"
    
    End Sub
    Attached Files Attached Files
    Last edited by tfagan1978; 03-23-2017 at 11:35 AM. Reason: adding a sample workbook

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to copy rows based on multiple criteria from one worksheet to another ?
    By Caster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2015, 06:27 AM
  2. Moving data from one worksheet to another based on criteria
    By dwhite30518 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-30-2014, 07:53 AM
  3. [SOLVED] Mark or Delete Rows based on Matching Multiple Criteria in another worksheet
    By clearbluez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2012, 02:38 PM
  4. [SOLVED] Moving rows to a different sheet based on yes/no criteria
    By mpc_2012 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-25-2012, 06:01 AM
  5. Replies: 6
    Last Post: 11-29-2010, 04:04 AM
  6. Moving rows to separate worksheet if criteria is met
    By lee4clp in forum Excel General
    Replies: 16
    Last Post: 08-11-2010, 12: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