Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
does anyone know how to program a cell when every single click on that cell with mouse button, the value of the cell will add 1. for example: Cell A1 had a value of 7, when i click on cell A1, the value will go up to 8 and so on. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dylan,
Right-click the Sheet Tab, View Code, Insert this: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 1 Then Target.Value = Target.Value + 1 End Sub If the Column is A then add 1 It will activate every time you select the cell. Unlike clicking a cell it only triggers when you change the selection from a different cell. "Dylan" wrote in message ... Hi, does anyone know how to program a cell when every single click on that cell with mouse button, the value of the cell will add 1. for example: Cell A1 had a value of 7, when i click on cell A1, the value will go up to 8 and so on. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dylan,
Right-click the Sheet Tab, View Code, Insert this: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 1 Then Target.Value = Target.Value + 1 End Sub If the Column is A then it adds 1 It will activate every time you select the cell. Unlike clicking a cell it only triggers when you change the selection from a different cell. Rob "Dylan" wrote in message ... Hi, does anyone know how to program a cell when every single click on that cell with mouse button, the value of the cell will add 1. for example: Cell A1 had a value of 7, when i click on cell A1, the value will go up to 8 and so on. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() -----Original Message----- Dylan, Right-click the Sheet Tab, View Code, Insert this: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 1 Then Target.Value = Target.Value + 1 End Sub If the Column is A then it adds 1 It will activate every time you select the cell. Unlike clicking a cell it only triggers when you change the selection from a different cell. Rob "Dylan" wrote in message ... Hi, does anyone know how to program a cell when every single click on that cell with mouse button, the value of the cell will add 1. for example: Cell A1 had a value of 7, when i click on cell A1, the value will go up to 8 and so on. . hi Rob, thanks for help. it works. what i see is that the whole column will be affected. could you teach me how to amend the script for only a particular Cell instead? also could i do it such that the value change On_click instead of clicking elsewhere then back on the cell. thanks very much. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Dylan
One way: Change the code to the following (now only A1 is counted): Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Cells.Count 1 Then Exit Sub If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub Else Target.Value = Target.Value + 1 end if End Sub hi Rob, thanks for help. it works. what i see is that the whole column will be affected. could you teach me how to amend the script for only a particular Cell instead? also could i do it such that the value change On_click instead of clicking elsewhere then back on the cell. thanks very much. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Dylan,
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If not intersect (Target, Range("A1")) Is Nothing Then Target.Value = Target.Value + 1 End If End Sub -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Dylan" wrote in message ... -----Original Message----- Dylan, Right-click the Sheet Tab, View Code, Insert this: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 1 Then Target.Value = Target.Value + 1 End Sub If the Column is A then it adds 1 It will activate every time you select the cell. Unlike clicking a cell it only triggers when you change the selection from a different cell. Rob "Dylan" wrote in message ... Hi, does anyone know how to program a cell when every single click on that cell with mouse button, the value of the cell will add 1. for example: Cell A1 had a value of 7, when i click on cell A1, the value will go up to 8 and so on. . hi Rob, thanks for help. it works. what i see is that the whole column will be affected. could you teach me how to amend the script for only a particular Cell instead? also could i do it such that the value change On_click instead of clicking elsewhere then back on the cell. thanks very much. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dylan,
I don't think there is a trivial way to capture onclick for a worksheet. Because SelectionChange fires even when you use the cursor keys to enter that cell, I suggest another approach: Create a button and assign this macro to it, which in this example increments selection if it falls within the range A1:B20 If selection is outside of bounds, then it beeps as an error. Sub Increment_Click() Dim rng As Range, rngSel As Range Set rngSel = Intersect(Selection, Range("A1:B20")) If Not rngSel Is Nothing Then For Each rng In rngSel rng.Value = rng.Value + 1 Next Else Beep End If End Sub Rob "Dylan" wrote in message ... -----Original Message----- Dylan, Right-click the Sheet Tab, View Code, Insert this: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 1 Then Target.Value = Target.Value + 1 End Sub If the Column is A then it adds 1 It will activate every time you select the cell. Unlike clicking a cell it only triggers when you change the selection from a different cell. Rob "Dylan" wrote in message ... Hi, does anyone know how to program a cell when every single click on that cell with mouse button, the value of the cell will add 1. for example: Cell A1 had a value of 7, when i click on cell A1, the value will go up to 8 and so on. . hi Rob, thanks for help. it works. what i see is that the whole column will be affected. could you teach me how to amend the script for only a particular Cell instead? also could i do it such that the value change On_click instead of clicking elsewhere then back on the cell. thanks very much. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I create a click on + symbol to open a root and click on -. | Excel Discussion (Misc queries) | |||
How to change syperlink from single click to double click | Excel Worksheet Functions | |||
Disabling click and right-click on the Picture I inserted in an Excel document | Excel Worksheet Functions | |||
Click on graph bar to execute a double-click in a pivot table cell | Charts and Charting in Excel | |||
Click on cell-calendar drops down-click on date-date fills cell. . | Setting up and Configuration of Excel |