Based on what I found here it is possible to change cells with an UDF and insert a formula.
It is a little bit cumbersome (maybe there is someone out there who can improve it) but it works. You also need to do a recalculation what you can't trigger from the function getValue and the sub addFormula. You must put it somewhere else. The parameter rg is the cell where you want to put the formula. Make sure is is not the cell where you put getValue.
Function getValue(rg As Range, path As String, file As String, sheet As String, ref As String)
Evaluate "addFormula( " & Chr(34) & rg.Address & Chr(34) & "," & Chr(34) & "'" & path & "[" & file & "]" & sheet & "'!" & ref & Chr(34) & ")"
getValue = ""
End Function
Sub addFormula(trgAddress As String, myFormula As String)
Dim trgRg As Range
Set trgRg = Range(trgAddress)
trgRg.Formula = "=" & myFormula
End Sub
In the worksheet selection change I added the calculate method. This is for sure not the best way to do it but it shows it is possible.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Calculate
End Sub
And that how you can use it: The function is in D5, the result in E5
