I have been stuck on this for awhile now, need to move rows to another worksheet or workbook. The 1st part should find all rows marked cancelled (Column AG is "Y"). 2nd part should find all rows marked ready (Column AH is "Y"). Code runs, but results are very strange. Does not move all rows, also seams to copy row 1 (headers). This is what I have so far:
Like I said, with above code, I am getting very strange results. Anyone able to help with this?
Code:
If MsgBox("This will purge ALL records showing Cancelled as well as" & vbNewLine & "All records showing Ready for Finance, between:" & vbNewLine & vbNewLine & Format(StartDate, "dd MMM yyyy") & " and " & Format(EndDate, "dd MMM yyyy") & vbNewLine & vbNewLine & "Are you sure?", vbQuestion + vbYesNo) = vbYes Then
Me.sysMsgBox.Value = " Purging records marked Cancelled..."
Application.ScreenUpdating = False '---->Prevents screen flickering as the code executes.
Application.DisplayAlerts = False '---->Prevents warning "pop-ups" from appearing.
'--------------------------------
' Look for all Cancelled records
'--------------------------------
Range("AG2", Range("AG" & Rows.Count).End(xlUp)).AutoFilter Field:=1, Criteria1:="Y" 'Filters Column AG for "Y"
UpdateStatus
CTotal = nCancelledCalls
Range("A2", Range("AZ" & Rows.Count).End(xlUp)).Copy wsCancelled.Range("A" & Rows.Count).End(xlUp)(2) ' Copies row data from Columns A - AZ & transfers it to Cancelled into the next available row.
Range("A2", Range("AZ" & Rows.Count).End(xlUp)).Delete '---->Deletes the data from MRC Database. This also prevents duplicates in Cancelled.
wsMRC.Activate '----> Takes you back to MRC Database.
Application.CutCopyMode = False '---->Prevents the "marching ants" from bordering the copied rows of data.
If ActiveSheet.AutoFilterMode Then
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
ElseIf ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
'----------------------------------------
' Look for all Ready for Finance Records
'----------------------------------------
Range("AH2", Range("AH" & Rows.Count).End(xlUp)).AutoFilter Field:=1, Criteria1:="Y" 'Filters Column AH for "Y"
UpdateStatus
FTotal = nClosedCalls
Range("A2", Range("AZ" & Rows.Count).End(xlUp)).Copy wsFinance.Range("A" & Rows.Count).End(xlUp)(2) ' Copies row data from Columns A - AZ & transfers it to Finance into the next available row.
Range("A2", Range("AZ" & Rows.Count).End(xlUp)).Delete '---->Deletes the data from MRC Database. This also prevents duplicates in Finance.
wsMRC.Activate '----> Takes you back to MRC Database.
Application.CutCopyMode = False '---->Prevents the "marching ants" from bordering the copied rows of data.
If ActiveSheet.AutoFilterMode Then
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
ElseIf ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
Total = CTotal + FTotal
If Total = 0 Then
Me.sysMsgBox.Value = " Admin: No records found. No records have been purged."
Else
Me.sysMsgBox.Value = " Admin: " & Total & " total record(s) purged. " & FTotal & " record(s) marked ready for finace and " & CTotal & " marked cancelled."
End If
Else
Me.sysMsgBox.Value = " Admin: Cancelled. No records have been purged."
Application.CutCopyMode = False '---->Prevents the "marching ants" from bordering the copied rows of data.
Application.DisplayAlerts = True '---->Resets the default.
Application.ScreenUpdating = True '---->Resets the default.
Exit Sub
End If
Application.CutCopyMode = False '---->Prevents the "marching ants" from bordering the copied rows of data.
Application.DisplayAlerts = True '---->Resets the default.
Application.ScreenUpdating = True '---->Resets the default.
UpdateStatus
UpdateScreen