J'essaie d'écrire une instruction if mais j'ai besoin d'extraire une valeur de la matrice/matrice "matrix". Je ne peux pas obtenir VBA pour obtenir h pour égaler la valeur dans l'emplacement 1,1 dans "matrice". J'ai déjà imprimé la matrice pour m'assurer qu'elle enregistre correctement les valeurs et c'est le cas. Comment obtenir la valeur dans la matrice en dehors de la boucle dans laquelle a été créée?Obtention d'une valeur hors d'une matrice à l'extérieur de la boucle dans laquelle elle a été créée
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' sans "préserver" efface tout le contenu du tableau. http://www.excel-easy.com/vba/examples/dynamic-array.html –