LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Auto Update Function

The best you can do is make your function recalculate when it's supposed to.

For that to happen, you want to make sure that any reference in your UDF is
passed to it through the formula:

If your UDF depends on A1 and B1, then using this:

Function myFunc(rng1 as range, rng2 as range) as double
'no validation at all
myfunc = rng1.value + rng2.value
end function

and in the worksheet:
=myfunc(a1,b1)

Is much better than:

Function DontUseThis(rng1 as range) as double
dontusethis = rng1.value + rng1.offset(0,1).value
end function

and in the worksheet:
=dontusethis(a1)

If B1 changes, the excel doesn't know that it needs to recalc that cell with the
formula.

You could use this (still Don't use it!)

Function DontUseThis2(rng1 as range) as double
application.volatile
dontusethis2 = rng1.value + rng1.offset(0,1).value
end function

and in the worksheet:
=dontusethis2(a1)

But that means that the cell with the function could be one calculation behind.
If you change B1 and that doesn't cause excel to recalc, then your cell with the
formula will look pretty, but it'll be wrong.


Brite wrote:

Hi there,

I'm created a function using macros, and i want to know how to make it so
that when ever something on the worksheet changes the function will
recalculate and update itself. How do I go about doing this?

thanks in advance

Ryan


--

Dave Peterson
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sometimes formuli in workbook don't auto update with auto-recal on PE2 Excel Worksheet Functions 1 October 12th 06 03:49 PM
Auto Update ExcelStress Excel Worksheet Functions 0 July 19th 05 07:36 PM
excel links update not working in auto, calculations in auto Mikey Boy Excel Worksheet Functions 0 December 7th 04 11:53 PM
auto update xyncro Excel Worksheet Functions 0 November 5th 04 03:58 PM
auto update xyncro Excel Worksheet Functions 0 November 5th 04 11:03 AM


All times are GMT +1. The time now is 02:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"