View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld[_2_] Ron Rosenfeld[_2_] is offline
external usenet poster
 
Posts: 1,045
Default Need to Capture the initial value of a cell.

On Tue, 19 Mar 2013 10:50:24 +0000, dpk2307 wrote:


HI,

I need to capture the initial value of a cell into another cell and
store it permanently even if the parent cell value is changed any number
of times.
For Ex: When the sheet was opened, say the A1 value was 25, then same
should be assigned to B1, when I change A1 any number of times, still
the B1 value should be 25 itself.


You need to use VBA to do that. One way is with a worksheet selection_change event code.

To enter this event-triggered Macro, right click on the sheet tab.
Select "View Code" from the right-click drop-down menu.
Then paste the code below into the window that opens.

====================================
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, [a1]) Is Nothing Then
If [b1].Text = "" Then
[b1].Formula = "=IF(A1="""","""",A1)"
Else
[b1].Value = [b1].Value
End If
End If
End Sub
===============================