我试图学习如何为H列中的单元格标记"完成"它复制整行并将其粘贴到名为"完成"的新页面中。并从我当前页面中删除该行。
我自己尝试录制它,但一直打破它。如果我做得对,我不知道。
到目前为止,这是我的代码:
Controllers
答案 0 :(得分:0)
正如您在评论中所说,如果您有一条明确的错误消息:
预期结束子
这意味着您的代码缺少End Sub
来关闭子代码!只需在代码末尾添加它即可。
以下是您的代码(End Sub
...),已改进:
Sub Completed_Move()
'Completed_Move Macro
Dim SrchRng As Range, RowRg As Range, CellRg As Range
Dim wS1 As Worksheet, wSC As Worksheet
Dim i as Long
With ThisWorkbook
Set wS1 = .Sheets("Sheet1")
Set wSC = .Sheets("Completed")
End With 'ThisWorkbook
Set SrchRng = wS1.Range("H1:H500")
For i = SrchRng.Cells(SrchRng.Rows.Count,1).Row To SrchRng.Cells(1,1).Row Step -1
'If "Complete" is part of value in H
If InStr(1, SrchRng.Cells(i,1).Value, "Complete") Then
With wSC
wS1.Range("A" & SrchRng.Cells(i,1).Row & ":N" & SrchRng.Cells(i,1).Row).Copy .Range("A" & .Range("A" & .Rows.Count).End(xlUp).Row + 1)
End With 'wSC
SrchRng.Cells(i,1).Rows("2:1").EntireRow.Delete Shift:=xlUp
End If
Next i
End Sub