Don’t think that I’m laughing at you - I’m showing joy that I was able to guess the source of the error … it seems that I was able …
Look in the text of code - you see, the line with the description of the function
Function FindCreateNumberFormatStyle (_
sFormat As String, Optional doc, Optional locale)
is divided into two lines, the underscore symbol is a sign of the operator wrapping on a new line. No other characters are expected after it. But it seems that when copying to the clipboard, something was added there, invisible.
Please try this - sample spreadsheet with macro.ods (57.6 KB)