How to Fix Excel Custom Function Returning #VALUE! Error on Different Computers
Question details
A custom VBA function returns a #VALUE! error on certain computers, particularly Excel for Mac or specific Windows installations, due to missing system components.

- Product
- Microsoft Excel
- Device & OS
- Windows and Mac
- Scenario
- A user is running a shared workbook containing custom VBA functions that rely on specific system objects to process data.
- Observed behavior
- The custom function fails and outputs #VALUE! because the code uses CreateObject("System.Collections.ArrayList"), which is a .NET framework component unavailable on Mac and missing or disabled on some Windows PCs.
Before modifying your VBA code, identify whether the users experiencing the issue are on a Mac or Windows environment, and ensure you have a backup copy of your macro-enabled workbook.
Replace ArrayList with a Native VBA Collection
Switch from using the .NET ArrayList to Excel's native VBA Collection object, which is fully supported across both Windows and Mac environments.
The System.Collections.ArrayList relies on the Windows .NET framework. Because macOS does not natively support .NET, and some Windows installations might lack the necessary framework versions, this object creation fails. Using a native VBA Collection ensures cross-platform compatibility.
Press ALT + F11 on your keyboard (or Option + F11 on Mac) to open the Visual Basic for Applications Editor.
In the Project Explorer pane, find the Module containing the custom function that is returning the #VALUE! error and double-click to open it.
Find the line of code that reads 'Set myObj = CreateObject("System.Collections.ArrayList")' and replace it with 'Dim myObj As New Collection'.
Modify any ArrayList-specific methods (like .Sort or .Contains) in your code to work with the VBA Collection. You may need to write custom helper functions for sorting, as VBA Collections do not have a built-in sort method.
Save your workbook and test the newly updated function on both a Mac and a Windows PC to ensure the #VALUE! error is resolved.

Use Native VBA Arrays for Complex Sorting
If your custom function relies heavily on sorting (which ArrayList handles natively but Collection does not), convert your data structure to a native VBA array.
Try WPS Office for Seamless Spreadsheet Management
If you are encountering persistent macro compatibility issues or cross-platform errors with Excel, consider switching to WPS Office. WPS Spreadsheet offers a robust, user-friendly environment with strong support for standard spreadsheet functions without the bloat.
- 1. Download and install: Visit the official WPS Office website to download and install the free software on your device.
- 2. Open your workbook: Launch WPS Spreadsheets and click File > Open to select your existing Excel workbook.
- 3. Work seamlessly: Edit your data, formulas, and charts using an interface that feels instantly familiar.

Frequently Asked Questions
Why does the #VALUE! error only appear on my Mac and not my Windows PC?
Mac computers do not have the Windows .NET framework installed. Any VBA code attempting to create a .NET object like System.Collections.ArrayList will immediately fail on macOS, resulting in a #VALUE! error.
Can I install .NET on my Mac to fix this Excel VBA error?
No, the Mac version of Excel does not support creating COM objects or interacting with the .NET framework through the VBA CreateObject method. You must rewrite the code to use native VBA structures.
How do I know exactly which custom function is causing the #VALUE! error?
Press ALT + F11 to open the VBA Editor, go to 'Debug' in the top menu, and click 'Compile VBAProject'. You can also step through the code line-by-line using F8 to see exactly which CreateObject call throws the error.
Can I sort a native VBA Collection like I did with an ArrayList?
Unlike an ArrayList, a native VBA Collection does not have a built-in .Sort method. To sort data, you will need to implement a custom sorting algorithm within your VBA module or transfer the data to an array, sort the array, and populate the collection.




