The substitute function in Calc has an occurrence parameter to specify which occurrence of the string match should be substituted, if it is left blank then all occurrencies should be substituted. If it is left blank it returns Err:502 it is not possible to substitute all occurrencies
Just discovered that it was caused by having a comma in the expression. =SUBSTITUTE(A2," ","",) fails with Err:502 =SUBSTITUTE(A2," ","") works fine.
Hi @Mick, thanks for expose what the problem was. Fixed is not the proper way to close in this way. https://bugs.documentfoundation.org/page.cgi?id=fields.html