Big problem with custom function

Jibse

New Member
Joined
Jan 8, 2009
Messages
38
Hello,

I have one custom function (not volatile) on one sheet, in more than 2000 cells. It works, but if I do a calculation in an another sheet which has no relations with the first one, the calculation on this first sheet is wrong (something like not terminated) and I have to do a CalculateFullRebuild.

Thanks for your help.
 
It would be easier if you can upload a workbook to a site like OneDrive / Dropbox and then post a link here so I can see the function in a workbook that doesn't work for you.
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
0AX6ma.gif


Then, if you do a calculation on Sheet2 (F9 for example, even a full calculation), the result will be 150. You have to go back to Sheet1 to recalculate. After, if you replace OFFSET(...) by the range, the problem is solved.
 
Upvote 0
OK I should have looked closer at the rest of the function code. You have an unqualified reference to ranges in your code here:
Code:
ra5 = Range(Cells(5, r2.Column), Cells(5, 22)).Value

when your code recalculates, it will refer to the active sheet, not the one containing the function. You also should actually make your function volatile if you refer to cells in the function that are not passed as arguments - otherwise your function will be incorrect when those cells are changed, unless the supplied arguments are also changed.
 
Upvote 0
Oh, Yes ! Thanks a lot. It works now. And thank you also because now I understand better the question of volatile.
Have a wonderful WE !
 
Upvote 0
You do not need to add Application.Volatile False to a function to not make it volatile - that is the default.

Are you sure ? Because I read the contrary in the VBA Help. Perhaps it's a false traduction ?

kamXw5.gif
 
Upvote 0
Yes, I'm sure. The Help file means that the default value of the argument that you pass to Application.Volatile is True. That just means that if you use:
Code:
Application.Volatile
on its own, it's the same as using:
Code:
Application.Volatile True

It doesn't mean that all UDFs are volatile by default - that would be the worst design decision ever!
 
Upvote 0

Forum statistics

Threads
1,215,554
Messages
6,125,487
Members
449,233
Latest member
Deardevil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top