Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count <= 1 Then
'éä¸çåå æ ¼æ¯å¦åªæä¸ä¸ªï¼é²æ¢ä¸æ¬¡å¯¹å¤ä¸ªåå æ ¼å¤å¶ãå é¤çæä½ï¼å®¹æ导è´å¤±è¯¯
If Target.Column = 2 And Trim(Target.Value) <> "" Then
'å æ å¨ç¬¬4åå§åï¼å¹¶ä¸å½ååå æ ¼çå¼ä¸ä¸ºç©º
If Target.Offset(0, 1).Value = "" Then
'å¤æå³è¾¹çåå æ ¼å 容æ¯å¦ä¸ºç©ºï¼å¦æææ°å¼ï¼
'表ææ¯ä¿®æ¹å½åå§ååå æ ¼ï¼åä¸ç¨éæ°èµäºæ¶é´;
'å¦æ为空ï¼å表ææ¯æ°å¢ä¸ä¼è ï¼å ¶å³è¾¹çåå æ ¼éæ°èµäºæ¶é´
Target.Offset(0, 1).Value = Now()
'å°å½ååå æ ¼å³è¾¹åå æ ¼çæ°å¼è®¾ä¸ºå½åç³»ç»æ¶é´
End If
ElseIf Target.Column = 2 And Trim(Target.Value) = "" Then
'å¦æå æ æå¨åå æ ¼æ¯ç¬¬2åå§åï¼å¹¶ä¸å½ååå æ ¼çå¼ä¸ºç©ºï¼
'表æå é¤äºæ个ä¸ä¼è ï¼å³è¾¹åå æ ¼çæ¶é´ä¹ç¸åºå é¤
Target.Offset(0, 1).Value = ""
'å°å½ååå æ ¼çå³è¾¹åå æ ¼çæ°å¼è®¾ä¸ºç©ºå¼
End If
End If
End Sub
参照附件~
请告诉我如何做?
追答你有vba基础吗?没有的话,告诉你也没用。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
编上你的程序
End Sub