I wrote an earlier post about a way to get this error when upgrading VBA from an earlier version of Dynamics SL to either v.2015 or v.2018. But I ran into a new way to get it today (other than just writing a bug into your code, which is the usual way to get it).
NEVER check Tools > Options > Code Settings > Require Variable Declaration in the SL Customization Manager VB Editor. That will add “Option Explicit” to the top of all your files. While that may help in the files you wrote, it will also add it (again) to the top of the VBTools_VBA module. You won’t probably think to look there. There is already an “Option Explicit” underneath the comment containing the copyright, etc. from Microsoft Dynamics. Having a new one above that comment may stump you for a while, at least until you think to look in a file you shouldn’t change… or run across this post.
It will also be added when you import a perfectly good customization that works in other environments, such as production.