UDF Recalculation

showard1

New Member
Joined
Aug 5, 2010
Messages
14
Hi all

Hopefully a simple problem. I have a UDF in a spreadsheet where all the inputs are on 1 worksheet as is the result. In fact the function is used several times on the worksheet to show a range of scenarios.

The function is fairly simple math, but was easier to do as a UDF that using what would be quite long formula's.

However how do I force the worksheet automatically re-calculate if I change one or more of the statis input values (there are only 5)

Hopefully somone can help
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Sorry, no that doesnt work. Perhaps I have not explained well enough

here a simplified version of the UDF code I used to debug the concept. If anyone changes the contents of cells D2, or D7 to D9, I need the UDF to recalculate.

Code:
Function pool(ack)
 
Q2 = Worksheets(4).Range("D7").Value * 1000
Q2P = 0
Q3 = Worksheets(4).Range("D8").Value * 1000
Q3P = 0
Q4 = Worksheets(4).Range("D9").Value * 1000
Q4P = 0
ppc = Worksheets(4).Range("D2").Value
ackq = ack / 3
If ackq >= Q2 Then
Q2P = ackq * ppc
Else: End If
If ackq >= Q3 Then
Q3P = ackq * ppc
Else: End If
If ackq >= Q4 Then
Q4P = ackq * ppc
Else: End If
 
pool = Q2P + Q3P + Q4P
 
End Function
 
Upvote 0
I tried a simpler UDF like this and it recalculated

Code:
Function pool(ack)
Application.Volatile
'
'rest of code
 
Upvote 0
OK found the problem. If I refreshed the UDF cells first then it worked.

Clearly the change to the UDF had not "transferred"

Many thanks for your help
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,256
Members
452,901
Latest member
LisaGo

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