0
Warum bekomme ich "Subskript out of range" in meiner Zeile T(k) = Cells(k + 1, 4).Value - z
?VBA _Error 9 Index außerhalb des Bereichs
Public Sub find()
Dim i, j, k, h As Integer
Dim T() As Double
Dim z As Double
Range("E1").Activate
i = ActiveCell.Row
j = ActiveCell.Column
While Not IsEmpty(Cells(i, j - 2).Value)
z = Cells(i, j - 2).Value
k = 0
While Not IsEmpty(Cells(k + 1, 4).Value)
T(k) = Cells(k + 1, 4).Value - z
k = k + 1
Wend
For h = 0 To k
If T(h) = Application.WorksheetFunction.Min(Abs(T(k))) Then
Cells(i, j).Value = Cells(h + 1, 4).Value
End If
Next
i = i + 1
Wend
End Sub
Mögliche Duplikat [Bestücken von VBA dynamische Arrays] (https://stackoverflow.com/questions/8850984/populating-vba-dynamic-arrays) –
Diese Frage richtet sich Ihr Problem: https: // stackoverflow.com/questions/8850984/populating-vba-dynamic-arrays/8851086#8851086 Achten Sie darauf, mehr als nur die erste Antwort zu lesen! –