Excel Error Codes

How to Fix Excel Custom Function Returning #VALUE! Error on Different Computers

Huma Ashraf ChHuma Ashraf Ch Nov 2, 2026 870 views

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.

How to Fix Excel Custom Function Returning #VALUE! Error on Different Computers
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 you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press ALT + F11 on your keyboard (or Option + F11 on Mac) to open the Visual Basic for Applications Editor.

2
Locate the affected custom function

In the Project Explorer pane, find the Module containing the custom function that is returning the #VALUE! error and double-click to open it.

3
Replace the ArrayList declaration

Find the line of code that reads 'Set myObj = CreateObject("System.Collections.ArrayList")' and replace it with 'Dim myObj As New Collection'.

4
Update collection methods

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.

5
Test the function

Save your workbook and test the newly updated function on both a Mac and a Windows PC to ensure the #VALUE! error is resolved.

Replace ArrayList with a Native VBA Collection
Cross-Platform Compatibility: Using native VBA structures like Collections or Arrays is the safest way to ensure your macro-enabled workbooks run seamlessly for all users.
Free Microsoft Office alternative

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. 1. Download and install: Visit the official WPS Office website to download and install the free software on your device.
  2. 2. Open your workbook: Launch WPS Spreadsheets and click File > Open to select your existing Excel workbook.
  3. 3. Work seamlessly: Edit your data, formulas, and charts using an interface that feels instantly familiar.
Free and lightweight Microsoft Office alternativeHighly compatible with Microsoft Excel formats (.xlsx, .xls, .csv, .xlsm)Familiar user interface requiring zero learning curveCross-platform support across Windows, macOS, Linux, and mobile devices
QA img-9

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.