As threads with tag "office-excel-itpro" focus on general questions of Excel clients, but your issue seems to be related to code.
I would suggest you post a new question on the following forums.
Office developer community
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.