I have run some tests but so far, I have not been able to emulate the problem.
Are you using Option Explicit as the first line in the module and then declaring the variables with the Dim statement? If not, try inserting Option Explicit at the start of the module and then declare the variables. After declaring the variables, Select menu item Debug -> Compile and it will identify any variables that have not been declared. More information on declaring variables at the following Microsoft link.
https://learn.microsoft.com/en-us/office/vba/language/concepts/getting-started/declaring-variables
Also, I am wondering if it is specific types of variables so could you please post some code and tell us which line is producing the error.