Reputation: 3
I would like to put a value to A1 and when I changed A1 I want to keep the first entered value in another cell.
Would that be possible ?
Thanks
Upvotes: 0
Views: 1549
Reputation: 16
Here is a solution using formulas, only. It requires that you switch the iterative calculations on in Excel options. You can set it to 1 iteration.
You only need to enter the following formula into B1:
=IF(ISBLANK(C1),IF(ISBLANK(A1),B1,IF(B1="",A1,B1)),"")
A1 is the cell whose value is to be remembered, B1 is the memory location, C1 is the reset button.
Upvotes: 0
Reputation: 96753
Insert the following event macro in the worksheet area:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range, N As Long
Set A = Range("A1")
If Intersect(Target, A) Is Nothing Then Exit Sub
If Cells(1, 2).Value = "" Then
N = 1
Else
N = Cells(1, 2).End(xlUp).Row + 1
End If
Application.EnableEvents = False
A.Copy Cells(N, "B")
Application.EnableEvents = True
End Sub
Every time you enter a value in A1, that value will be recorded in the first availab1e cell in column B
Because it is worksheet code, it is very easy to install and automatic to use:
If you have any concerns, first try it on a trial worksheet.
If you save the workbook, the macro will be saved with it. If you are using a version of Excel later then 2003, you must save the file as .xlsm rather than .xlsx
To remove the macro:
To learn more about macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
and
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
To learn more about Event Macros (worksheet code), see:
http://www.mvps.org/dmcritchie/excel/event.htm
Macros must be enabled for this to work!
Upvotes: 2