有人可以推薦任何免費程序來計算點擊單元格內的點擊次數。Excel中的點擊次數
對於例子試想像電子表格 我點擊A1單元格的值顯示1 然後我再次單擊A1單元格的值顯示2等 如果我點擊A3單元格的地方在小區A3節目點擊次數之間1等
如果像這樣的東西可以作爲一個宏在Excel中(2003年請)請建議或任何其他免費程序,你可能會意識到,請讓我知道。感謝您的幫助,並感謝您提前。
有人可以推薦任何免費程序來計算點擊單元格內的點擊次數。Excel中的點擊次數
對於例子試想像電子表格 我點擊A1單元格的值顯示1 然後我再次單擊A1單元格的值顯示2等 如果我點擊A3單元格的地方在小區A3節目點擊次數之間1等
如果像這樣的東西可以作爲一個宏在Excel中(2003年請)請建議或任何其他免費程序,你可能會意識到,請讓我知道。感謝您的幫助,並感謝您提前。
Excel沒有用於鼠標左鍵單擊的工作表事件。
它確實有'SelectionChange'事件,這可以與API調用相結合來檢查是否單擊了鼠標左鍵。
此代碼需要進入您針對的工作表的Project Explorer區域的Sheet對象。
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Key As Integer
If Target.Count > 1 Then Exit Sub
''//If multiple cells selected with left click and drag
''// then take no action
Key = GetKeyState(MOUSEEVENTF_LEFTDOWN)
If Key And 1 Then
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
''//Check to see if cell contains a number, before
''// trying to increment it
Application.EnableEvents = False
Target.Resize(1, 2).Select
Application.EnableEvents = True
''//Resize the selection, so that if the cell is clicked
''// for a second time, the selection change event is fired again
End If
End If
End Sub
儘管此代碼的工作,它可以增加,即使沒有離開用戶點擊他們的鼠標單元格值。
我會建議使用「BeforeDoubleClick」事件,而不是如果可能的話。這是內置於Excel中,比上面的代碼更可靠。
爲了增加單元格值,用戶需要雙擊單元格。
此代碼需要進入您針對的工作表的Project Explorer區域的Sheet對象。
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
''//Check to see if cell contains a number, before
''// trying to increment it
Application.EnableEvents = False
Target.Resize(1, 2).Select
Application.EnableEvents = True
''//Resize the selection, so that if the cell is clicked
''// for a second time, the selection change event is fired again
Cancel = True
''//Stop the cell going into edit mode
End If
End Sub
哇真棒,這符合我的需要。非常感謝。 – rockbala 2010-03-21 11:29:42
是的,那是可能的。您可以使用this link提供的VBA腳本的一些變體。希望這可以幫助。
你能定義目標到某個區域A1:L29嗎?這段代碼選擇整張紙 – 2012-03-06 18:42:44