VBA数组调用问题:"缺少数组或用户定义类型"
1个回答
展开全部
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim zone As Object, name1()
Set zone = Worksheets(2).[a1:e1]
name1 = Array(1, 2, 3, 4, 5)
Call range_yuebao(zone, name1)
End Sub
Option Explicit
Sub range_yuebao(zone As Object, ByRef arr())
Dim i&
For i = 0 To UBound(arr)
zone.Cells(1, i + 1) = arr(i)
Next i
End Sub
name为系统的,尽量不用。
ByRef必须要,否则出错。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询