No, actually the problem has to do with identifying the cell. During a simulation, (particularly a VBA simulation), we have to check whether we've already updated the value for a given cell - and if so, to retain the last value.
The reason for this is that VBA may cause the spreadsheet to recalculate and we can't update the values. For example, if you use Goalseek within a VBA simulation it may recalculate the spreadsheet many times to converge on a solution. While this is happening we have to ensure that the random values we generate are consistent.
To do that, we need to know what cell the value is in. When the function is called from VBA like this, we can't properly identify a cell and as a result the value never updates.
There are two ways to resolve this: either (1) don't use a VBA simulation (it's not needed in the above code), or (2) put the random function into a spreadsheet cell and get the value from there.
This is not ideal but it will solve the problem.
I hope that's helpful,
Alex
alex@riskamp.com