I have a user defined function that calculates the current date if the value of another cell (FileName) is not "". In other words, when someone updates a new file name, the date of when they did the update auto-populates. Once this value is calculated, I would like to copy and paste it's value only (PasteSpecial Values) back into the same cell. Essentially, once the value is calculated, I want to kill the formula so that it cannot be used again. I just want the initial calculated value to remain. I've tried calling a sub-routine (Hardcode) with no luck. I'm honestly not sure if this is the best approach. Even if it is, I can't seem to get the syntax correct. Any thoughts on the most efficient way to accomplish my desired task?
VBA Code:
Function LoadDate(FileName As String)
If (FileName <> "") Then
LoadDate = Date
Call Hardcode (LoadDate)
Else
LoadDate = ""
End If
End Function
Sub HardCode(LoadDate As Date)
Range(LoadDate).Copy
Range(LoadDate).PasteSpecial xlPasteValuesAndNumberFormats
End Sub