View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default User Function Not Recalculating

You could add "application.volatile" and the UDF will recalc the next time that
excel recalcs.

But if you change something that the function needs but doesn't cause a
recalculation, your UDF could be incorrect.

If possible, it's better to pass the cells that the UDF needs to use so that
excel can know when to calculate that function.

function myFunc(rng1 as range, rng2 as range)
myfunc = rng1.value + rng2.value
end function

is better than:

function myFunc(rng1 as range)
myfunc = rng1.value + rng1.offset(0,1).value
end function



ZootRot wrote:

Excel 2003

I've created a simple user function in VBA. It uses data in a cell to
calculate an answer. It works fine, except when I change the input data,
the function doesn't recalculate. All other recalcs work on the
spreadsheet.

I have checked that auto recalc is on, and but even when I press F9, the
recalc doesn't work. I have to edit the cell formula or copy and paste the
formulae again in order to recalc.

Any thoughts on resolving this?


--

Dave Peterson