I have the following code below, but I am not having any luck applying code that will do the following: If the cell in column E states, “Complete” and there is no associated date in column F, I’d like an error message to pop up and not allow the data to be transferred/deleted. Can you please assist?
Sub LaPorte()
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("La Porte").UsedRange.Rows.Count
J = Worksheets("La Porte-Closed").UsedRange.Rows.<wbr>Count
If J = 1 Then
If Application.WorksheetFunction.<wbr>CountA(Worksheets("La Porte-Closed").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("La Porte").Range("E1:E" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "Complete" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("La Porte-Closed").Range("A" & J + 1)
xRg(K).EntireRow.Delete
If CStr(xRg(K).Value) = "Complete" Then
K = K - 1
End If
J = J + 1
End If
Next
Application.ScreenUpdating = True
ActiveWorkbook.Save
Sub LaPorte()
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("La Porte").UsedRange.Rows.Count
J = Worksheets("La Porte-Closed").UsedRange.Rows.<wbr>Count
If J = 1 Then
If Application.WorksheetFunction.<wbr>CountA(Worksheets("La Porte-Closed").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("La Porte").Range("E1:E" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "Complete" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("La Porte-Closed").Range("A" & J + 1)
xRg(K).EntireRow.Delete
If CStr(xRg(K).Value) = "Complete" Then
K = K - 1
End If
J = J + 1
End If
Next
Application.ScreenUpdating = True
ActiveWorkbook.Save
[TABLE="width: 0"]
<tbody>[TR]
[TD][TABLE="width: 0"]
<tbody>[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]
<tbody>[TR]
[TD][TABLE="width: 0"]
<tbody>[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]