Cell format and Calculation

  • Thread starter Thread starter Raymond
  • Start date Start date
R

Raymond

I want to enter a number into a cell and this number will automatically add
its value into another cell. However, after the pressing the enter key, I
want the entered number to be disappeared, leaving room for the next number.
How can I accomplish this? Or is this possible?
 
Try putting this into the worksheet code where you want this to occur, the
input cell is A1 the summation cell is B1

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value > 0 Then
Range("B1").Value = Range("B1").Value + Range("A1").Value
Range("A1").Value = ""
End If
End Sub

Cheers
Nigel
 
From Excel press Alt-F11 to open the VBA editor. Then press Ctrl R to open
the Project Viewer. This lists the object in the workbook. Double Click
the worksheet into which you wish to apply this programme. Paste the entire
code in the new window that opended. Close the VBA editor and try it. You
can edit the cells etc., by re-opening the code as above and changing the
range values A1 and B1 as required.


Cheers
Nigel
 
and if you make a mistake entering the number, what do you want to have
happen (if you forget what number you entered; but you know it is wrong,
then what). Generally a running total with no audit trail can be
problematic.
 
It's easier to right click on the sheet tab, select View Code, and pop
the macro in there.

Pay heed to Tom's astute observation, as well.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
Back
Top