我在我的工作表中运行了下面的代码,如果行为空,我需要停止运行它。请注意,当该行为空白时,我需要停止显示日期或让我将其删除在A(1)列中。问题是,当我删除行中的数据时,我无法删除列A中的日期 - 宏正在运行,不能让我这样做。
Sub Worksheet_Change(ByVal faixa As Range)
Dim dados As Range
Set dados = Range("A1:AI400")
If Not Intersect(faixa, dados) Is Nothing Then
Application.EnableEvents = False
dados.Cells(faixa.Row, 1).Value = Date
Application.EnableEvents = True
End If
End Sub
答案 0 :(得分:0)
听起来你的代码正在运行,即使你打算留下一个空格,如果我理解正确的话。要更正它,以下内容将允许您留下一个空白单元格:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal faixa As Range)
Dim dados As Range
Set dados = Range("A1:AI4000")
If Not Intersect(faixa, dados) Is Nothing Then
If Not faixa = "" Then
dados.Cells(faixa.Row, 1).value = Date
End If
End If
End Sub