How retain calculated value in a cell despite changes to inputs

P

pnic

Please, could any one help me to save the result resent in a cell following a
calculation (by functions), despite changing the parameters affecting the
results?

For example;

If I do a*b=c

I want the result “c†to be saved in a cell while I change “b†to “d†in the
same function.

If now a*d=e

I would like a row, somewhat like the below

“câ€
“eâ€
..
..
..

Hope this is clear.

Thank you
 
G

Gary''s Student

Let's say in C1 we have
=A1+B1
and we want to record the values in C1 in the cells below whenever we change
either A1 or B1.

Enter the following macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Range("A1:B1")
If Intersect(r, Target) Is Nothing Then Exit Sub
n = Cells(Rows.Count, "C").End(xlUp).Row + 1
Cells(n, "C").Value = Range("C1").Value
End Sub

The first time either A1 or B1 is changed the value in C1 is copied to C2,
the next time to C3, etc.


REMEMBER the worksheet code area, not a standard module.
 

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