VBA global variables, multiple workbooks

前端 未结 4 1732
轻奢々
轻奢々 2021-01-14 19:08

I have a VB application, that uses some global variables to store data that is required by multiple forms and modules, this works fine. However if a user opens up another wo

4条回答
  •  暖寄归人
    2021-01-14 20:06

    Public myvar as Variant
    

    Variables declared as Public are scoped to the workbook they're in. If you have another workbook with myvar, changing it's value in one won't change it in the other. Perhaps you have an event that's setting that variable from the activesheet that's firing in both projects and setting the variables to the same thing.

提交回复
热议问题