excel2007vba使用全局變量?
聲明全局變量可以在文檔任何位置(For循環、If判斷內除外)。比如:Option ExplicitPublic a As StringSub aa() a = "public" MsgBox aEnd Sub以上代碼可執行。--------------------------------Option ExplicitPublic a As StringSub aa() a = "public" MsgBox a Dim i As Single For i = 1 To 6 Public b As Single b = i MsgBox b NextEnd Sub以上代碼提示: 編譯錯誤: Sub 或 Function 中的屬性無效以上。