cornishpasty55
New Member
- Joined
- Feb 2, 2021
- Messages
- 3
- Office Version
- 2019
- Platform
- Windows
Hello,
I would like to move rows from one sheet to another, depending on the content in Column Z. The value for go-ahead is "0" (as this means there are 0 blank cells in the row).
I have managed to move my completed rows from "Complete" to the next available row in "Archive". This pasting into "Archive" starts in Column A. However, I would like the data to start pasting in Column B of Sheet 2, thus leaving Column A empty. I'm thinking I'll need the use of the Offset function, but I'm not sure how to get this working.
Any help is greatly appreciated!
I would like to move rows from one sheet to another, depending on the content in Column Z. The value for go-ahead is "0" (as this means there are 0 blank cells in the row).
I have managed to move my completed rows from "Complete" to the next available row in "Archive". This pasting into "Archive" starts in Column A. However, I would like the data to start pasting in Column B of Sheet 2, thus leaving Column A empty. I'm thinking I'll need the use of the Offset function, but I'm not sure how to get this working.
Any help is greatly appreciated!
VBA Code:
Sub Submit_Request()
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("Complete").UsedRange.Rows.Count
J = Worksheets("Archive").UsedRange.Rows.Count
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Archive").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("Complete").Range("Z3:Z" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "0" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("Archive").Range("A" & J + 1)
xRg(K).EntireRow.Delete
If CStr(xRg(K).Value) = "0" Then
K = K - 1
End If
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub