目前正在制作电子表格以跟踪工作进度。排" C"从单元格C12:C3000下拉,如果选择此项,则#34;项目已关闭"我需要将行剪切并粘贴到工作表中#34;项目已关闭"切割行后没有空行。
我遇到过这个VBA代码并根据自己的需要进行了调整。但无济于事。我对VBA世界很陌生,所以不确定我做得对。
Sub cut_paste() Dim i As Variant Dim endrow As Integer Dim ASR As Worksheet,LS As Worksheet
Set ASR = ActiveWorkbook.Sheets("In Progress")
Set LS = ActiveWorkbook.Sheets("Project Closed")
endrow = ASR.Range("A" & ASR.Rows.Count).End(xlUp).Row
For i = 3 To endrow
If ASR.Cells(i, "C").Value = "Project Closed" Then
ASR.Cells(i, "C").EntireRow.cut Destination:=LS.Range("A" & LS.Rows.Count).End(xlUp).Offset(1)
End If
Next
End Sub
答案 0 :(得分:0)
如果您要剪切行,并且不想留空行,请尝试以下方法:
For i = endrow To 3 Step -1
If ASR.Cells(i, "C").Value = "Project Closed" Then
ASR.Cells(i, "C").EntireRow.Copy Destination:=LS.Range("A" & LS.Rows.Count).End(xlUp).Offset(1)
ASR.Cells(i, "C").EntireRow.Delete
End If
Next
这应该通过ASR表,复制任何匹配,然后删除该行并继续。