Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 输出数组内容而不选择每个元素_Arrays_Vba_Output - Fatal编程技术网

Arrays 输出数组内容而不选择每个元素

Arrays 输出数组内容而不选择每个元素,arrays,vba,output,Arrays,Vba,Output,我有以下多维数组结构 Type Wedge C407 As Long C417 As Long C507 As Long C516 As Long C607 As Long C617 As Long C707 As Long

我有以下多维数组结构

Type Wedge
    C407                As Long
    C417                As Long
    C507                As Long
    C516                As Long
    C607                As Long
    C617                As Long
    C707                As Long
    C716                As Long
    C807                As Long
    C817                As Long
    C907                As Long
    C916                As Long
End Type
上面有大约35个元素

Global myWedge() As Wedge
ReDim myWedge(99, 4)
我已经填充了数组,但现在想将数组的内容输出到工作表中。以前在其他较小的数组中,我输出了每个元素,如下所示

  'Output IOTT Number and Duration
        For a = 1 To 4
           If YGBL(x, a).IOTT > 0 Then sOutput.Cells(x + 4, IOTTCol) = YGBL(x, a).IOTT
               IOTTCol = IOTTCol + 2
           If YGBL(x, a).IOTTDUR > 0 Then sOutput.Cells(x + 4, IOTTDUR) = YGBL(x, a).IOTTDUR
               IOTTDUR = IOTTDUR + 2
        Next a
但是考虑到元素的数量,我只想通过元素循环并将其放入一个表中,而不必对每个元素执行上述操作

这可能吗

谢谢

使用函数

Function PropertyOf(wedgeType As Wedge, index As Integer) As Long
  Dim w As Long

  With wedgeType
    Select Case index
      Case 1
         w = .C407
      Case 2
         w = .C417
      Case 3
         w = .C507
      ....
    End Select
  End With
  PropertyOf = w
End Function
然后


Huy,谢谢你的解决方案,只是在努力解决w=myWedge(x,a)什么是“x”,我只是从你的样本YGBL(x,a)中复制。。。。因此,在本例中,您可以为x=1到99创建另一个外部循环。。。。
Dim w As Wedge
For a = 1 To 4
  w = myWedge(x, a)
  For c = 1 To 35
     p = PropertyOf(w, c)
     If p > 0 Then
        ' Do your stuff here
     End If
  Next c
Next i