UDF across a range only partially returning values (XL2007)

AOB

Well-known Member
Joined
Dec 15, 2010
Messages
664
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
Hi guys,

I have a UDF which takes a range as in input and returns a text string. The UDF is fairly complex (it queries Outlook to concatenate various contact information based on the range parameter) and takes a couple of seconds to run for one instance (i.e. one single range) so I generally turn the automatic calculations off and then fire the calculation manually when everything's ready.

I've applied the UDF to a table, so it should perform the same function across a number of rows (roughly 300 at the moment) and what's strange is, when all the 'processing' is complete, there are only values in some cells / rows, and not in others?

I figured it must be a failure to identify the contact (which should return a null / ZLS anyway), but if I click into an individual cell (which appears blank) and F2+Enter (to retrigger the calculation in that cell), it works fine, and populates with the expected string.

In some cases, it returns an error (#VALUE!), which again I assumed to be due to an unhandled error in the VBA. But again, if I click into such a cell, F2+Enter, it produces the desired result.

Why is this, and how can I fix it so it works across the whole table when I just Calculate Sheet, rather than having to go through the whole sheet and calculate each cell individually?

Cheers!

AOB
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,221,831
Messages
6,162,242
Members
451,756
Latest member
tommyw

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