nangel
Automotive
- Dec 7, 2004
- 10
I would like to allow a end user to update a excel spreadsheet by adding 1 to a cell. Please see the example below:
Example
On Monday the output was
A B C D E F
1 t1 9
2 t2 7
3
4 ttl 16
5
On Tuesday a User opens the file and adds one to "1B".
A B C D E F
1 t1 10
2 t2 7
3
4 ttl 17
5
What I would like to do verify that the user added only one to the original cell and if a mistake was made I would like for the user to be able to go back to its original number and not let the end user delete the number completely. In this case the cell should go back to (B1=9) and the user should not be able to delete it.
The code I am using to add or subtract one from the cell is:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Target.Value = Target.Value + 1
ActiveCell.Offset(-1, 0).Select
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Target.Value = Target.Value - 1
ActiveCell.Offset(-1, 0).Select
End Sub
Any suggestions or comments will be very appreciated.
Thank you in advance for your help!
Example
On Monday the output was
A B C D E F
1 t1 9
2 t2 7
3
4 ttl 16
5
On Tuesday a User opens the file and adds one to "1B".
A B C D E F
1 t1 10
2 t2 7
3
4 ttl 17
5
What I would like to do verify that the user added only one to the original cell and if a mistake was made I would like for the user to be able to go back to its original number and not let the end user delete the number completely. In this case the cell should go back to (B1=9) and the user should not be able to delete it.
The code I am using to add or subtract one from the cell is:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Target.Value = Target.Value + 1
ActiveCell.Offset(-1, 0).Select
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Target.Value = Target.Value - 1
ActiveCell.Offset(-1, 0).Select
End Sub
Any suggestions or comments will be very appreciated.
Thank you in advance for your help!