我最近一直在运行这个宏时遇到困难,当它检测到对特定单元格区域的修改时会自动运行。到目前为止,我在表单代码中插入此宏的第一个子程序运行顺利...我试图为另一个子程序复制这个相同的宏,但它不起作用。
我认为可能是Elseif不适合这个特定的工作表代码。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
For Each cell In Target
If Not Intersect(cell, Range("C5:C1000")) Is Nothing Then
Dim currCell As Range
For Each currCell In ActiveSheet.Range("D5:D1000")
If IsEmpty(currCell) And currCell.Offset(0, -1) = "Open" Then
currCell = Format(Now(), "dd/mm/yyyy")
End If
Next currCell
ElseIf Not Intersect(cell, Range("C5:C1000")) Is Nothing Then
Dim currCell2 As Range
For Each currCell2 In ActiveSheet.Range("I5:I1000")
If IsEmpty(currCell2) And currCell2.Offset(0, -5) = "Closed" Then
currCell2 = Format(Now(), "dd/mm/yyyy")
End If
Next currCell2