I am quite surprised that such a simple functionality seems to be unsupported in VBA. Say I want to write value 0.5 to the cell E7 inside a function (not a sub!):
Public Function writeToCell() As Integer
ActiveSheet.Range("E7").Value = 0.5
writeToCell = 0
End Function
And when I call the function writeToCell in another cell say F9, there is a value error, and the writing statement fails to be executed.
Why can we not write to cells inside a function? Is there any workaround? My problem is that the values I will write to some pre-designated cells depend on some intermediate results calculated inside the function. So I will have to write to the cells inside this function when I call the function from the target cell in my worksheet.
Selection_ChangeorWorksheet_Changeevent, orApplication.OnTimeto make the updating automatic and more frequent - Tim Stack