我应该能够编辑 J 列中除“已发布”、“已关闭”之外的任何更新文本。每次我编辑文本时,日期都应在下一列单元格中自动更新。例如,我需要在明天更改 J3 列中的文本“已过时”,并且明天的日期应该在 L3 单元格中更新,因为之前单元格 K3 被今天的更新占用(以下是代码)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Integer
x = 2
With Sheets("sheet2")
.Unprotect "test"
.Cells.Locked = False
End With
For x = 2 To 32
If WorksheetFunction.CountA(Range(Cells(x, 1), Cells(x, 10))) <> 0 And Cells(x, 11).Value = "" Then
Cells(x, 11).Value = Date
Else: GoTo ende
End If
ende:
Next x
Call nottoday
End Sub
Sub nottoday()
For x = 2 To 32
If IsDate(Cells(x, 11).Value) And Cells(x, 11).Value < Date Then
ActiveSheet.Unprotect Password:="test"
Range(Cells(x, 1), Cells(x, 11)).Locked = True
End If
Next x
Sheets("Sheet2").Protect "test"
End Sub