excelvba

Forbidden custom function name in Excel


While I was fighting with VBA code, trying to create a new custom defined function, I saw that R1MQR2 in function name was giving me an error while calling it in a cell formula.

Public Function R1MQR2(Re1 As String, Re2 As String) As Boolean
    R1MQR2 = True
End Function

After trying some combinations, anything like R1R2, and C1C2, even if there is more characters in the middle, is not possible to be called from a cell, even if Excel itself suggest your custom function. It will fail.

In the other hand, V1V2 is working

Is this specified anywhere? I could see R1R2 maybe referring to some range, but R1xxR2? What am I missing?


Solution

  • I'd guess it's related to the R1C1 reference style. A workaround is to preface with the module name, e.g.

    =Module1.R1MQR2("foo","bar")
    

    enter image description here