你好!程式修改之後的程式碼如下:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim r, c As Long
Application.EnableEvents = False "程式碼只執行一次
Set mysheet1 = ThisWorkbook.Worksheets("Sheet1") "定義Sheet1工作表
r = Target.Row "獲取改變的行
c = Target.Column "獲取改變的列
If c = 12 And Target.Value "" Then "如果L列變更且不為空白,則執行A&B
mysheet1.Cells(r, 17) = mysheet1.Cells(r, 1) & mysheet1.Cells(r, 1)
End If
If r > 3 And Target.Value "" Then "提示是哪個單元格變更(只是對應的行)
MsgBox "單元格的值已改變,現在是:" & r
"********************************************************************
If Target.Row > 2 And Target.Column = 12 Then
Range("N" & r).Value = Format(Date, "YYYYMMDD ") & Format(Time, "h:mm:ss")
If Target.Column = 12 Then
If Target.Offset(0, 1) = "" Then
Target.Offset(0, 1) = Format(Date, "YYYYMMDD ") & Format(Time, "h:mm:ss")
Else
Application.EnableEvents = True
End Sub
https://iknow-pic.cdn.bcebos.com/09fa513d269759eecfa96051befb43166c22dfab
https://iknow-pic.cdn.bcebos.com/5bafa40f4bfbfbed199636e574f0f736aec31f58
你好!程式修改之後的程式碼如下:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim r, c As Long
Application.EnableEvents = False "程式碼只執行一次
Set mysheet1 = ThisWorkbook.Worksheets("Sheet1") "定義Sheet1工作表
r = Target.Row "獲取改變的行
c = Target.Column "獲取改變的列
If c = 12 And Target.Value "" Then "如果L列變更且不為空白,則執行A&B
mysheet1.Cells(r, 17) = mysheet1.Cells(r, 1) & mysheet1.Cells(r, 1)
End If
If r > 3 And Target.Value "" Then "提示是哪個單元格變更(只是對應的行)
MsgBox "單元格的值已改變,現在是:" & r
End If
"********************************************************************
If Target.Row > 2 And Target.Column = 12 Then
Range("N" & r).Value = Format(Date, "YYYYMMDD ") & Format(Time, "h:mm:ss")
If Target.Column = 12 Then
If Target.Offset(0, 1) = "" Then
Target.Offset(0, 1) = Format(Date, "YYYYMMDD ") & Format(Time, "h:mm:ss")
Else
End If
End If
End If
Application.EnableEvents = True
End Sub
https://iknow-pic.cdn.bcebos.com/09fa513d269759eecfa96051befb43166c22dfab
https://iknow-pic.cdn.bcebos.com/5bafa40f4bfbfbed199636e574f0f736aec31f58