1

I already answered a similar question here, about periods . in a name, but I'm unsure about whether the same rule holds for backslashes.

Is it possible to write a UDF in VBA that contains a period in the name?

If the UDF is written in an external library, will the library allow backslashes in function names, and will Excel allow me to use that function name in a worksheet formula? Will excel require me to escape the character in some way?

Or, perhaps a backslash is valid when used to escape another character?

1 Answer 1

2

If you are talking about an UDF created via the Excel C API (XLL based), it is possible.

You just need to register the name (argument pxProcedure in xlfRegister) with an escape character (i.e to register My\Func you employ My\\Func). Then you can call it directly from a cell without escaping the character.

See below (also with two backslashes) :

TwoBackSlashExcel

[eBackSlashExcel[2]

Edit : With a single backslash character :

single

2
  • Thanks. Will Excel permit the \ to be the leading, trailing, or only character, or is that moot, because the function will be preceded by _xll.? Jan 31, 2017 at 19:13
  • 1
    Yes, I just tested it, it works for all cases (leading,trailing and only character).
    – Malick
    Jan 31, 2017 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.