Excel not recalculating cells containing a UDF

GaryStainburn

New Member
Joined
Sep 14, 2010
Messages
13
Hi folks,

I have a number of functions which are short-cuts to a master function providing function arguments.

This function then calls a number of lookups to ranges in another workbook returning values based on codes, and return the sum of these values.

If I edit the cell (e.g. press F2) it recalculates the cell I am in and the correct new value appears. However, I cannot get Excel to automatically recalculate all cells.

Recalculating is set to automatic, and even running recalc manually doesn't update the cells. I have tried adding 'Application.Volatile' to each of the cells too but this has not fixed the problem.

Can anyone suggest what to do next. I am using Excel 2007 and 2010 and the problem occurs in both versions.

Thanks.

Gary
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
We'd have to see the UDF but I would suspect you are not passing the changing values as arguments to the UDF.
 
Upvote 0
Any recommendations on improving these functions will be very welcome. I don't write VB at all, so I have no doubt there will be scope.

The short-cut functions appear in thousands of cells within the spreadsheet are are there (a) to reduce the amount of typing and (b) make it easier to change the worksheet names later if required.

The short-cut functions all look like this:

Code:
Function LNL(ParamArray Nominals() As Variant)
  Application.Volatile
  Dim V() As Variant
  V = Nominals()
  LNL = nGetNL("RingwaysLeeds", V)
End Function
The main function is:

Code:
Function nGetNL(SName, Nominals() As Variant)
  Application.Volatile
  Dim CNumber As Long
  Dim ULimit As Long
  Dim NlResult As Double
  Dim Period As String
  Dim Sh
  ULimit = UBound(Nominals)
  CNumber = 3                            ' Default to this month
  If UCase(Nominals(ULimit)) = "Y" Then  ' "Y" = This year to date
    CNumber = 4
    ULimit = ULimit - 1
  End If
  If UCase(Nominals(ULimit)) = "P" Then  ' "P" = Prior year this month
    CNumber = 5
    ULimit = ULimit - 1
  End If
  If UCase(Nominals(ULimit)) = "PY" Then ' "PY" = Prior year year to date
    CNumber = 6
    ULimit = ULimit - 1
  End If
    
  NlResult = 0
  For n = LBound(Nominals) To ULimit
    NlResult = NlResult + WorksheetFunction.VLookup(Nominals(n), Workbooks("Period_TB.xlsx").Sheets(SName).Range("A:G"), CNumber, True)
  Next n
  nGetNL = NlResult * -1
End Function

An example cell content is
Code:
=LNL(000001,000121,002345,123232,'P')
 
Last edited:
Upvote 0
Hi folks,

I'm still working on this, but I'm going round in circles getting nowhere.

Can anyone suggest what I can try next.

Thanks.

Gary
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,486
Members
452,917
Latest member
MrsMSalt

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