Hi All!
Goal:
Entire row on Outstanding Issuance & Invoice sheet to be cut and pasted to either the Missing Primary Policies tab or the Completed Accounts tab. Once the entire row is cut and pasted, the original blank row should be deleted.
This should only happen if the cell in column S for the active row contains a date. I have been trying to use Not IsBlank but got nowhere. Various dates will be entered. If the cell in column S for the active row is blank, nothing should be done.
If the above criteria is met and the cell contains a date, then the status in Column G determines which tab the row is pasted to. If the cell in Column G = Missing Primary Policy(ies) the row is pasted in the next blank row of the Primary Policies Outstanding tab. If the cell in Column G = Account Complete - All Info Received the row is pasted in the next blank row of the Completes Accounts tab.
This should happen starting with row 3 until a blank row occurs.
Current Code:
The below code is what I am working with now. It partially works, but it does not loop through properly. Anything with Account Complete - All Info Received seems to all be moving, however not all the rows with column G cell value as Missing Primary Policy(ies) seem to be moving. I also need to add the criteria so this only happens is the cell for the active row in Column S is not blank.
Sub Update()
Columns.EntireColumn.Hidden = False
Rows.EntireRow.Hidden = False
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim C As Long
Dim D As Long
I = Worksheets("Outstanding Issuance & Invoice").UsedRange.Rows.count
C = Worksheets("Completed Accounts").UsedRange.Rows.count
D = Worksheets("Primary Policies Outstanding").UsedRange.Rows.count
If C = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Completed Accounts").UsedRange) = 0 Then C = 0
End If
Set xRg = Worksheets("Outstanding Issuance & Invoice").Range("G1:G" & I)
On Error Resume Next
Application.ScreenUpdating = False
For Each xCell In xRg
If CStr(xCell.Value) = "Account Complete - All Info Received" Then
xCell.EntireRow.Copy Destination:=Worksheets("Completed Accounts").Range("A" & C + 1)
xCell.EntireRow.Delete
C = C + 1
End If
Next
Application.ScreenUpdating = True
If D = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Primary Policies Outstanding").UsedRange) = 0 Then D = 0
End If
Set xRg = Worksheets("Outstanding Issuance & Invoice").Range("G1:G" & I)
On Error Resume Next
Application.ScreenUpdating = False
For Each xCell In xRg
If CStr(xCell.Value) = "Missing Primary Policy(ies)" Then
xCell.EntireRow.Copy Destination:=Worksheets("Primary Policies Outstanding").Range("A" & D + 1)
xCell.EntireRow.Delete
D = D + 1
End If
Next
Application.ScreenUpdating = True
End Sub
Bookmarks