1
我想写一个if语句,但我需要从“矩阵”矩阵/数组中获取一个值。我无法让VBA将h等于“矩阵”中的时隙1,1的值。我已经打印了矩阵,以确保它正确地保存了值并且是。如何获得循环外矩阵的值是在?从它创建的循环外创建一个矩阵的值
Option Explicit
Option Base 1
Private Sub CommandButton1_Click()
Dim numberofcases As Single, r As Integer, i As Single, j As Integer, c As
Single
Dim matrix() As String, max As Single
Dim loadmatrix() As String, loadtypes As Single, numbertypes As Single
Dim STAADloadmatrix() As String, countrow As Single, countcolumn As Single
Dim h as single
max = ((Cells(Rows.count, "B").End(xlUp).Row))
loadtypes = ((Cells(Rows.count, "L").End(xlUp).Row))
j = 1
c = 5
i = 1
ReDim matrix(i, j)
For r = 2 To max
ReDim matrix(i, j)
j = 1
If Cells(r, c) = "" Then
ElseIf Cells(r, c) > 0 Then
matrix(i, j) = Cells(r, c)
j = 2
ReDim matrix(i, j)
matrix(i, j) = Cells(r, (c - 2))
i = i + 1
End If
Next r
h = matrix(1,1)
End sub
'ReDim'没有“保存”会删除所有数组内容。 http://www.excel-easy.com/vba/examples/dynamic-array.html –