#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Counting clicks

I want to count the clicks in any of a large range of cells in one column.
This is for purposes of collecting clicks like a person making hash marks on
an inventory count sheet. There is some brilliant code on another forum but
it only works on a couple or a few cells, as named within the code. I cannot
make it work throughout a column. This is the code:

Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Address = "$A$5" Or target.Address = "$B$5" Then

oldvalue = target

Application.EnableEvents = False
If target.Value = 0 Then oldvalue = 0
target.Value = 1 + oldvalue
oldvalue = target.Value
Application.EnableEvents = True
End If
End Sub
Sub fixit()
Application.EnableEvents = True
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Counting clicks

Hi,

Try this. the fixit subroutine has probably been added for debugging and
does nothing


Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Column = (1) And target.Cells.Count = 1 Then

oldvalue = target

Application.EnableEvents = False
If target.Value = 0 Then oldvalue = 0
target.Value = 1 + oldvalue
oldvalue = target.Value
Application.EnableEvents = True
End If
End Sub

Mike

"rengewwj" wrote:

I want to count the clicks in any of a large range of cells in one column.
This is for purposes of collecting clicks like a person making hash marks on
an inventory count sheet. There is some brilliant code on another forum but
it only works on a couple or a few cells, as named within the code. I cannot
make it work throughout a column. This is the code:

Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Address = "$A$5" Or target.Address = "$B$5" Then

oldvalue = target

Application.EnableEvents = False
If target.Value = 0 Then oldvalue = 0
target.Value = 1 + oldvalue
oldvalue = target.Value
Application.EnableEvents = True
End If
End Sub
Sub fixit()
Application.EnableEvents = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,071
Default Counting clicks

Change your "IF" statement to something like:
If Not Intersect(Target, Columns("B:B")) Is Nothing Then
Change the column to suit. HTH Otto
"rengewwj" wrote in message
...
I want to count the clicks in any of a large range of cells in one column.
This is for purposes of collecting clicks like a person making hash marks
on
an inventory count sheet. There is some brilliant code on another forum
but
it only works on a couple or a few cells, as named within the code. I
cannot
make it work throughout a column. This is the code:

Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Address = "$A$5" Or target.Address = "$B$5" Then

oldvalue = target

Application.EnableEvents = False
If target.Value = 0 Then oldvalue = 0
target.Value = 1 + oldvalue
oldvalue = target.Value
Application.EnableEvents = True
End If
End Sub
Sub fixit()
Application.EnableEvents = True
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Counting clicks

Perhaps:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A:A")) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
Application.EnableEvents = True
End If
End Sub
--
Gary''s Student - gsnu200822


"rengewwj" wrote:

I want to count the clicks in any of a large range of cells in one column.
This is for purposes of collecting clicks like a person making hash marks on
an inventory count sheet. There is some brilliant code on another forum but
it only works on a couple or a few cells, as named within the code. I cannot
make it work throughout a column. This is the code:

Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Address = "$A$5" Or target.Address = "$B$5" Then

oldvalue = target

Application.EnableEvents = False
If target.Value = 0 Then oldvalue = 0
target.Value = 1 + oldvalue
oldvalue = target.Value
Application.EnableEvents = True
End If
End Sub
Sub fixit()
Application.EnableEvents = True
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Counting clicks

Works like a charm. Thank you.

"Mike H" wrote:

Hi,

Try this. the fixit subroutine has probably been added for debugging and
does nothing


Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Column = (1) And target.Cells.Count = 1 Then

oldvalue = target

Application.EnableEvents = False
If target.Value = 0 Then oldvalue = 0
target.Value = 1 + oldvalue
oldvalue = target.Value
Application.EnableEvents = True
End If
End Sub

Mike

"rengewwj" wrote:

I want to count the clicks in any of a large range of cells in one column.
This is for purposes of collecting clicks like a person making hash marks on
an inventory count sheet. There is some brilliant code on another forum but
it only works on a couple or a few cells, as named within the code. I cannot
make it work throughout a column. This is the code:

Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Address = "$A$5" Or target.Address = "$B$5" Then

oldvalue = target

Application.EnableEvents = False
If target.Value = 0 Then oldvalue = 0
target.Value = 1 + oldvalue
oldvalue = target.Value
Application.EnableEvents = True
End If
End Sub
Sub fixit()
Application.EnableEvents = True
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,393
Default Counting clicks

Small typo here. For first statement use
If Not Intersect(Target, Range("A:A")) is Nothing Then

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Gary''s Student" wrote in message
...
Perhaps:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A:A")) Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
Application.EnableEvents = True
End If
End Sub
--
Gary''s Student - gsnu200822


"rengewwj" wrote:

I want to count the clicks in any of a large range of cells in one
column.
This is for purposes of collecting clicks like a person making hash marks
on
an inventory count sheet. There is some brilliant code on another forum
but
it only works on a couple or a few cells, as named within the code. I
cannot
make it work throughout a column. This is the code:

Option Explicit
Dim oldvalue As Double
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Address = "$A$5" Or target.Address = "$B$5" Then

oldvalue = target

Application.EnableEvents = False
If target.Value = 0 Then oldvalue = 0
target.Value = 1 + oldvalue
oldvalue = target.Value
Application.EnableEvents = True
End If
End Sub
Sub fixit()
Application.EnableEvents = True
End Sub



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
Repetitive keystrokes and/or mouse clicks Lydia Ferguison Excel Discussion (Misc queries) 1 August 8th 08 07:00 PM
Double clicks do not open the file Aggie Excel Discussion (Misc queries) 1 November 12th 07 10:42 AM
How to have errr msg pop up when user clicks on locked cell perfection Excel Discussion (Misc queries) 4 May 29th 07 06:27 AM
auto hiding rows under category heading unless cursor clicks on to Daniel R Excel Discussion (Misc queries) 0 April 4th 07 06:12 PM
unable to open Excel file by double clicks Renyan Excel Discussion (Misc queries) 2 January 16th 05 01:07 AM


All times are GMT +1. The time now is 07:02 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"