Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to write a macro to count clicks in Excel?

Hello....I would like to write a macro/formula in Excel such that each click
in a cell will add 1 to another cell, ie the number of clicks will be
counted. It can be either a left or right click....Is this possible??
Thanks!!

Steve

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default How to write a macro to count clicks in Excel?

Rightclick on the worksheet tab that should have this behavior and select view
code.

Paste this into the code window:

Option Explicit

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("a1")) Is Nothing Then Exit Sub

Cancel = True

With Target.Offset(0, 1)
If IsNumeric(.Value) Then
.Value = .Value + 1
Else
Beep
End If
End With
End Sub

If you rightclick on A1, it'll add 1 to B1.

(You could use Worksheet_BeforeDoubleClick, too. But there isn't a single click
event.)



GoBoilerzz wrote:

Hello....I would like to write a macro/formula in Excel such that each click
in a cell will add 1 to another cell, ie the number of clicks will be
counted. It can be either a left or right click....Is this possible??
Thanks!!

Steve


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count and Reset Button Clicks Arlen Excel Discussion (Misc queries) 3 May 12th 10 04:33 AM
How to write a macro to count dates BEETAL Excel Worksheet Functions 8 December 17th 08 08:20 AM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
How to write a macro to get the system time in excel 97 Raj Excel Discussion (Misc queries) 6 April 20th 05 07:20 PM
How do I write a conditional statement in Excel to count if two c. marblelife Excel Worksheet Functions 2 January 16th 05 11:16 PM


All times are GMT +1. The time now is 07:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"