我有一個跟蹤器,用戶每天都會爲其添加行。 我需要一個顯示當前日期和用戶名的代碼,一旦單元被雙擊。合併列A將是日期單元格,列P將是用戶名。日期和用戶名(如果點擊)
我有一些代碼,但它顯示用戶和日期一旦打勾完成。現在我需要點擊。
Sub CheckBox_Date_Stamp()
Dim cbx As CheckBox
'Application.Caller returns the name of the CheckBox that called this macro
Set cbx = ActiveSheet.CheckBoxes(Application.Caller)
'.TopLeftCell returns the cell address located at the top left corner of the cbx checkbox
With cbx.TopLeftCell
'Check the checkbox status (checked or unchecked)
If cbx.Value = xlOn Then
' Checkbox is Checked
' User Name and Date-Time
.Offset(0, 1).Value = Environ("UserName")
.Offset(0, 2).Value = Now
Else
' Checkbox is unchecked; Clear cell contents?
.Offset(0, 1).ClearContents
.Offset(0, 2).ClearContents
End If
End With
End Sub
你能提供幫助嗎? 謝謝
這是可能改變這個,使得它在我點擊A1而不是B1時工作嗎?將單元格更改爲(1,1)是否工作? – Adam
@Adam - 它可以工作,但你必須改變它在代碼中顯示用戶名的單元格。 – Vityata
好的,難道這不可能在單擊單元格中顯示它嗎?我的意思是我點擊A1 - 日期在A1中彈出? – Adam