ClarkeJosh
New Member
- Joined
- Dec 23, 2020
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
I have looked through the threads an unable to find the answer, hoping someone can help me rectify the error in my VBA coding,
I have 2 sheets one labeled as Actions and one Labeled as Completed.
In actions sheet when the data in Column K is "Complete" i would like to move the whole row to Sheet "Completed"
Below is the coding i am using, but when i run the macro i get the error " Compile Error" Invalid Outside Procedure.
Any assistance rectifying the error would be greatly appreciated.
Coding im usung is:
Dim A As Long
Dim B As Long
Dim C As Long
A = Worksheets("Sheet1").UsedRange.Rows.Count
B = Worksheets("Sheet2").UsedRange.Rows.Count
If B = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Completed").UsedRange) = 0 Then B = 0
End If
Set xRg = Worksheets("Actions").Range("C1:C" & A)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(C).Value) = "Complete" Then
xRg(C).EntireRow.Copy Destination:=Worksheets("Completed").Range("A" & B + 1)
xRg(C).EntireRow.Delete
If CStr(xRg(C).Value) = "Complete" Then
C = C - 1
End If
B = B + 1
End If
Next
Application.ScreenUpdating = True
End
I have 2 sheets one labeled as Actions and one Labeled as Completed.
In actions sheet when the data in Column K is "Complete" i would like to move the whole row to Sheet "Completed"
Below is the coding i am using, but when i run the macro i get the error " Compile Error" Invalid Outside Procedure.
Any assistance rectifying the error would be greatly appreciated.
Coding im usung is:
Dim A As Long
Dim B As Long
Dim C As Long
A = Worksheets("Sheet1").UsedRange.Rows.Count
B = Worksheets("Sheet2").UsedRange.Rows.Count
If B = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Completed").UsedRange) = 0 Then B = 0
End If
Set xRg = Worksheets("Actions").Range("C1:C" & A)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(C).Value) = "Complete" Then
xRg(C).EntireRow.Copy Destination:=Worksheets("Completed").Range("A" & B + 1)
xRg(C).EntireRow.Delete
If CStr(xRg(C).Value) = "Complete" Then
C = C - 1
End If
B = B + 1
End If
Next
Application.ScreenUpdating = True
End