Excel VBA functions generating #REF depending on function name?

calendar_today Asked Apr 22, 2012
thumb_up 6 upvotes
history Updated April 16, 2026

Question posted 2012 · +5 upvotes

I’m using Excel 2010, and have defined the following 3 functions in spreadsheet’s Module.

Option Explicit

Public Function AAA() As Double

    AAA = 3
End Function

Public Function AAA2() As Double

    AAA2 = 4
End Function


Public Function AAA3AAA() As Double

    AAA3AAA = 5
End Function

When I reference the three functions in my spreadsheet by entering the following into 3 adjacent cells

=AAA()
=AAA2()
=AAA3AAA()

The second function generates a #REF error. The other functions work as expected. Anyone know why this is happening? The reason I’m asking is a few of my macros quit working when I upgraded from Office XP to Office 2010. After quite a bit of experimenting, it appears the function name itself is the culprit? The error did not occur in Excel from Office-XP.

Accepted answer +6 upvotes

Same thing happened to me. What I notice is that unlike the other two, “AAA2” could be the text of a cell address. I suspect that’s the problem.

Top excel-vba Q&A (6)

+6 upvotes ranks this answer #114 out of 136 excel-vba solutions on this site .