update cell without loosing previous data

S

Susan

My stock sheets are set up with a goods inwards colum. Every delivery I enter
my invoices into a goods recived colum. So the first entry is =2. Next entry
the following week I select the cell wich now has (=2) and in the tool bar
place the curser next to the 2 and type plus then the next entry. So =2+3.
and get a running total. Can ayone tell me how I can eliminate the need to
place the curser in the window and just select the cell and begin to type
updated data.
 
R

Rich

you could just double click on the cell and the do the + bit at the end of
the current formula,, but this would have the same effect as clicikng on the
formula bar
 
J

JE McGimpsey

One way:

Assume your goods inward column is column C. Put this in your worksheet
code module (right-click the worksheet tab and choose View Code):

Const nCOLUMN As Long = 3 'Column C
Dim sOldFormula As String

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If ActiveCell.Column = nCOLUMN Then
sOldFormula = ActiveCell.Formula
Else
sOldFormula = vbNullString
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If .Column = nCOLUMN Then
If .HasFormula Then Exit Sub 'already a formula
If IsNumeric(.Value) Then
On Error Resume Next
Application.EnableEvents = False
If Left(sOldFormula, 1) = "=" Then
.Formula = sOldFormula & "+" & .Value
Else
.Formula = "=" & .Value
End If
Application.EnableEvents = True
On Error GoTo 0
End If
sOldFormula = .Formula
End If
End With
End Sub

Change nCOLUMN to suit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top