I agree with Cliff, but think you should use Target rather than activecell.
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If target.count 1 then exit sub
if isempty(Range("Z1").Value) then
If Target.column =2 and Target.column <=21 then
If Not IsNumeric(Target.Value) Then
Exit Sub
ElseIf IsEmpty(Target.Value) Then
Target.Value = 0
Else
Target.Value = Target.Value + 1
End If
End If
End If
End Sub
This event fires whenever the cell is selected (either with the mouse or
manually moving into it, so I think you need a way to turn it off. I check
if Z1 is empty. If you want to turn it off, put an entry in Z1.
You would right click on the sheet tab and select view code. Then put in
code like the above.
--
Regards,
Tom Ogilvy
Cliff Myers wrote in message
...
I think I am understanding what you want. In your
worksheet_SelectionChange
envent add this code:
If Not IsNumeric(ActiveCell.Value) Then
Exit Sub
ElseIf IsEmpty(ActiveCell) Then
Exit Sub
Else
ActiveCell.Value = ActiveCell.Value + 1
End If
The code will check the activecell, if it is text it will do nothing, if
the
cell is blank, it will do nothing, else it will increase by one.
HTH
"Cali92" wrote in message
...
Hi everyone.
I need this, but still can't figure out how to do this...
I have a spreadsheet with A and B in which I insert people name and a
number, ie Carlo Gonella (A) 4 (B).
then on the same row I have a lot of cell with an initial value of 0.
(there are 20 cells)
My need is that when I left click on the cell, its value increase by
one...
So that I will have something like
A | B | C | D | E | F | G | H | I |
Carlo Gonella | 4 | 2 | 0 | 1 | 3 | 0 | 3 | 4 | and so on ....
But I really can't figure out where and what to code ...
I was thinking about a userform in which putting many buttons as the
names in the A column, and a number of txtboxes as the columns I need
to increase.
Selecting a name, the values will be the one referring to that person,
changing name they will change.
Thanks in advance for your help...
I Attach the baseline for what I need ...
Cali92
File Attached:
http://www.exceltip.com/forum/attach...?postid=281708
(scout1.xls)
------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from
http://www.ExcelForum.com/