我正在尝试将存档表添加到我的工作簿,其中收集封闭票。我希望从标有“票”的纸张中剪切的特定票证,并一旦其状态从开放到关闭,就会粘贴为标记为“档案”的纸张。我希望使用私有潜力来实现,以便它发生在单元格变化上。状态在第4列中找到。

如果可能的话,我假设也可以以另一个方式执行它。因此,如果重新打开票据,并且在“存档”纸上更改其状态,它将被切割并粘贴到“门票”表中。

这是我们到目前为止的代码。我们似乎可以让它工作。任何帮助将不胜感激。谢谢

Private Sub Worksheet_Change (ByVal Target As Range) 

If Target.Column = 4 Then 
If Target.Value = "Closed" Then
   R = Target.Row 
   Rows(R).Cut 
   Worksheets("Archive").Select
     With ActiveSheet
      lastrow = .Cells(.Rows.Count,"B").End(xlUp).Row
     End With
   Cells(lastrow,1).Select
   Selection.Paste
End If
End If 
End sub 
.

有帮助吗?

解决方案

只是对您当前的代码进行小修改:

If Target.Column = 4 Then
If Target.Value = "Closed" Then
   R = Target.Row
   Rows(R).Cut
   Worksheets("sheet3").Select
     With ActiveSheet
      lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
      .Cells(lastrow, 1).Select
      .Paste
     End With
End If
End If
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top