我需要列“F”中的单元格,以便在“J”列的同一行中更新培训日期时清除内容。
在工作表的VBA中(在VBE的VBAProject窗格中单击该工作表)。使用Worksheet_Change()
事件。这是一个事件,一大块代码,只要工作表发生变化就会执行。 Target
是一个特殊变量,它将包含代码执行时更改的范围/单元格:
Private Sub Worksheet_Change(ByVal Target As Range)
'Did something change in column J?
If Not Intersect(Target, Range("J:J")) Is Nothing Then
'Set the cell in Column F for the same row to nothing
Range("F" & Target.Row).ClearContents
End If
End Sub