![]() |
Mouse click to increase/decrease a cell value?
I need to incrementally increase or decrease cell values until I get an exact
result in a dependant cell:- 19.9, 19.8, 19.7...19.5...bingo! Is there a way that I can achieve this with mouse clicks...each click subtracts/adds 0.1 - or any other integer that I specify - to the cell value? |
Mouse click to increase/decrease a cell value?
With a double click,
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Address = "$A$1" Then 'Change to suit If IsNumeric(Target) Then On Error Resume Next Target = Target - 0.1 ActiveCell.Offset(0, 1).Select On Error GoTo 0 End If End If End Sub Mike Mike "Al" wrote: I need to incrementally increase or decrease cell values until I get an exact result in a dependant cell:- 19.9, 19.8, 19.7...19.5...bingo! Is there a way that I can achieve this with mouse clicks...each click subtracts/adds 0.1 - or any other integer that I specify - to the cell value? |
Mouse click to increase/decrease a cell value?
Al,
I missed you wanted to add or subtract so try this. A plus sign in B1 makes it add. B1 blank makes ot subtract. Mike Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Address = "$A$1" Then If IsNumeric(Target) Then On Error Resume Next If ActiveCell.Offset(0, 1).Value = "+" Then Target = Target + 0.1 Else Target = Target - 0.1 End If ActiveCell.Offset(0, 1).Select On Error GoTo 0 End If End If End Sub "Al" wrote: I need to incrementally increase or decrease cell values until I get an exact result in a dependant cell:- 19.9, 19.8, 19.7...19.5...bingo! Is there a way that I can achieve this with mouse clicks...each click subtracts/adds 0.1 - or any other integer that I specify - to the cell value? |
Mouse click to increase/decrease a cell value?
Wow, instant response...thanks v much. Afraid you are talking a language I
do not understand, so I'm going to take your routine and ask someone in my office if they can "translate" for me! Again, thanks for your help! "Mike H" wrote: Al, I missed you wanted to add or subtract so try this. A plus sign in B1 makes it add. B1 blank makes ot subtract. Mike Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Address = "$A$1" Then If IsNumeric(Target) Then On Error Resume Next If ActiveCell.Offset(0, 1).Value = "+" Then Target = Target + 0.1 Else Target = Target - 0.1 End If ActiveCell.Offset(0, 1).Select On Error GoTo 0 End If End If End Sub "Al" wrote: I need to incrementally increase or decrease cell values until I get an exact result in a dependant cell:- 19.9, 19.8, 19.7...19.5...bingo! Is there a way that I can achieve this with mouse clicks...each click subtracts/adds 0.1 - or any other integer that I specify - to the cell value? |
Mouse click to increase/decrease a cell value?
Al,
To use it right click the sheet tab you want to use it on and then click view code and paste the code in there. As to how it works it uses an Excel event (before double click) and if the cell double clicked is A1 it checks what is in the cell 1 cell to the right - offset(0,1) - if it finds a + sign it adds .1 to the target cell and if it doesn't it subtracts .1 Mike Mike "Al" wrote: Wow, instant response...thanks v much. Afraid you are talking a language I do not understand, so I'm going to take your routine and ask someone in my office if they can "translate" for me! Again, thanks for your help! "Mike H" wrote: Al, I missed you wanted to add or subtract so try this. A plus sign in B1 makes it add. B1 blank makes ot subtract. Mike Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Address = "$A$1" Then If IsNumeric(Target) Then On Error Resume Next If ActiveCell.Offset(0, 1).Value = "+" Then Target = Target + 0.1 Else Target = Target - 0.1 End If ActiveCell.Offset(0, 1).Select On Error GoTo 0 End If End If End Sub "Al" wrote: I need to incrementally increase or decrease cell values until I get an exact result in a dependant cell:- 19.9, 19.8, 19.7...19.5...bingo! Is there a way that I can achieve this with mouse clicks...each click subtracts/adds 0.1 - or any other integer that I specify - to the cell value? |
Mouse click to increase/decrease a cell value?
|
Mouse click to increase/decrease a cell value?
|
All times are GMT +1. The time now is 04:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com