我有一个宏,我开始编程,并有一个关于声明变量的问题。
到目前为止,这就是我所拥有的:
Dim wbTHMacro As Workbook
Dim wsRegulares As Worksheet
Dim wsRegularesDemitidos As Worksheet
Dim wsTempActivos As Worksheet
Dim wsTempJA As Worksheet
Dim wsTempFit As Worksheet
Dim wsTempDemitidos As Worksheet
Dim wsPresenceSystem As Worksheet
Dim wsResultados As Worksheet
Dim wsDLList As Worksheet
Dim wbRegularesBruto As Workbook
因为我会有更多的变量,所以可以直接写出它们而不是列出它们以使我的宏缩短?如果是这样,怎么样?他们进入下一行我将如何空间或继续?
非常感谢任何帮助。
答案 0 :(得分:1)
你可以这样做:
Dim wbTHMacro As Workbook, wsRegulares As Worksheet, wsRegularesDemitidos As Worksheet
Dim wsTempActivos As Worksheet, wsTempJA As Worksheet, wsTempFit As Worksheet
Dim wsTempDemitidos As Worksheet, wsPresenceSystem As Worksheet, wsResultados As Worksheet
Dim wsDLList As Worksheet, wbRegularesBruto As Workbook
就个人而言,我更愿意在我第一次使用它们时声明我的变量。我发现它更容易调试。