You can fill in the dependent cell (D2) using the User Defined Function (macroeconomic function VBA), which takes a C2-Cell value as an input parameter, returning the current date as an output.
Having C2 as an input parameter for UDF in D2 tells Excel that it needs to reevaluate D2 every time C2 changes (that is, if automatic formula calculation is enabled for the workbook).
EDIT:
Here is the code:
For UDF:
Public Function UDF_Date(ByVal data) As Date
UDF_Date = Now()
End Function
Like the formula in D2:
=UDF_Date(C2)
You will need to provide the D2-Cell date and time format, or it will show a numerical representation of the date value.
, , C2 D2.
:
, , , , Excel , D2 reset .
D2 C2, - C2.
, , UDF, , , UDF.
:
UDF, -, .
, :
UDF , .
UDF .
-,
. ,
, ,
( +
.) , , Excel
,
.
, .
, .
. .
Public Function UDF_Date(ByVal inData As Range) As Date
Dim wb As Workbook
Dim dProps As DocumentProperties
Dim pValue As DocumentProperty
Dim pDate As DocumentProperty
Dim sName As String
Dim sNameDate As String
Dim bDate As Boolean
Dim bValue As Boolean
Dim bChanged As Boolean
bDate = True
bValue = True
bChanged = False
Dim sVal As String
Dim dDate As Date
sName = inData.Address & "_" & inData.Worksheet.Name
sNameDate = sName & "_dat"
sVal = CStr(inData.Value)
dDate = Now()
Set wb = inData.Worksheet.Parent
Set dProps = wb.CustomDocumentProperties
On Error Resume Next
Set pValue = dProps.Item(sName)
If Err.Number <> 0 Then
bValue = False
Err.Clear
End If
On Error GoTo 0
If Not bValue Then
bChanged = True
Set pValue = dProps.Add(sName, False, msoPropertyTypeString, sVal)
Else
bChanged = pValue.Value <> sVal
If bChanged Then
pValue.Value = sVal
End If
End If
On Error Resume Next
Set pDate = dProps.Item(sNameDate)
If Err.Number <> 0 Then
bDate = False
Err.Clear
End If
On Error GoTo 0
If Not bDate Then
Set pDate = dProps.Add(sNameDate, False, msoPropertyTypeDate, dDate)
End If
If bChanged Then
pDate.Value = dDate
Else
dDate = pDate.Value
End If
UDF_Date = dDate
End Function