Before anyone can tell you how to resolve "it", we need to know what is causing this problem.
right after the let varMaxDate = Peek(...); statement. Reload your document and check the content of varMinDate and varMaxDate in the Settings->Variable Overview dialog. Do they contain numerical values?
I am getting the same error with a very similar script:
TempCalendar: LOAD $(varMinDate) + Iterno()-1 As Num, Date($(varMinDate) + IterNo() - 1) as TempDate AutoGenerate '1' While $(varMinDate) + IterNo()-1 <= $(varMaxDate) ;
I don't understand what should be checked about resident tables. This load statement isn't loading from a table. Its just loading from variables. I tried putting a comma after TempDate and it doesn't like it. I tried putting 'Resident [existing table name]' before the semicolon ; and it didn't like that either.