我的问题是 - 我在一个宏中定义了一个向量,我尝试从另一个宏中的向量中调用值。尽管所有对象都是公共的,但第二个宏不与向量配合。感谢您提出任何建议。
我的代码如下:
Public qj As Integer
Public pp_ii(5) As Variant
Public Sub Loop_over_pp()
Dim myarray As Variant
pp_ii = Array(51, 52, 53, 54, 55)
For qj = 0 To UBound(pp_ii)
Call Macro1
Next qj
End Sub
Public Sub Macro1()
Worksheets("List1").Range("A" & qj) = pp_ii(qj)
End Sub
答案 0 :(得分:1)
解决方案:
Public qj As Integer
Public pp_ii() As Variant
Public Sub Loop_over_pp()
pp_ii = Array(51, 52, 53, 54, 55)
For qj = 0 To UBound(pp_ii)
Call Macro1
Next qj
End Sub
Public Sub Macro1()
Worksheets("List1").Range("A" & qj + 1) = pp_ii(qj)
End Sub