Sub ReDimHilfe()
Dim Crash_names()
ReDim Crash_names(0 To 4, 1 To 3)
MsgBox "Dimensionen von Crash_names(0 To 4, 1 To 3)" & vbLf _
& "Untere Grenze Dimension 1: " & LBound(Crash_names, 1) & vbLf _
& "Obere Grenze Dimension 1: " & UBound(Crash_names, 1) & vbLf _
& "Untere Grenze Dimension 2: " & LBound(Crash_names, 2) & vbLf _
& "Obere Grenze Dimension 2: " & UBound(Crash_names, 2)
ReDim Crash_names(1 To 4, 0 To 1)
MsgBox "Dimensionen von Crash_names(1 To 4, 0 To 1)" & vbLf _
& "Untere Grenze Dimension 1: " & LBound(Crash_names, 1) & vbLf _
& "Obere Grenze Dimension 1: " & UBound(Crash_names, 1) & vbLf _
& "Untere Grenze Dimension 2: " & LBound(Crash_names, 2) & vbLf _
& "Obere Grenze Dimension 2: " & UBound(Crash_names, 2)
End Sub
Sub beispiel()
Dim meArray(5, 6, 7)
meArray(0, 1, 0) = "Test1"
meArray(1, 1, 6) = "Test2"
meArray(5, 6, 7) = "Test3"
MsgBox "1. Dimension: " & UBound(meArray, 1) & vbCr & _
"2. Dimension: " & UBound(meArray, 2) & vbCr & _
"3. Dimension: " & UBound(meArray, 3) & vbCr
End Sub
Die Anzahl Zeilen und Spalten der dritten Dimension ist die der Dimension 1 und 2.
Sub UboundHilfe()
Dim a, x, i1&, i2&, i3&
On Error GoTo Fehler
a = Array(1, Array(Array(1, 2, 3), Array(1, 3, 3), Array(1, 4, 3)), _
Array(Array(1, 5, 3), Array(1, 2, 3), Array(2, 3, 3), 2, Array(2, 5, 3)))
If IsArray(a) Then
For i1 = LBound(a, 1) To UBound(a, 1)
If IsArray(a(i1)) Then
For i2 = LBound(a(i1), 1) To UBound(a(i1), 1)
If IsArray(a(i1)(i2)) Then
For i3 = LBound(a(i1)(i2)) To UBound(a(i1)(i2))
x = a(i1)(i2)(i3)
Next
Else
x = a(i1)(i2)
End If
Next
Else
x = a(i1)
End If
Next
x = a
End If
Fehler:
With Err
Select Case .Number
Case 0
Case Else
MsgBox "Fehler-Nr.: " & .Number & vbLf & .Description
End Select
End With
End Sub
Sub t()
Dim crash_names(2, 2) As Variant
crash_names(0, 0) = 10
crash_names(1, 0) = 9
crash_names(2, 0) = 8
crash_names(0, 1) = 9
crash_names(0, 2) = 9
crash_names(1, 2) = 4
MsgBox "Ergebnis 1 = " & UboundSpecial(crash_names, 0)
MsgBox "Ergebnis 2 = " & UboundSpecial(crash_names, 1)
MsgBox "Ergebnis 3 = " & UboundSpecial(crash_names, 2)
End Sub
Function UboundSpecial(ar As Variant, iRow As Long) As Variant
Dim i As Long
For i = 0 To UBound(ar)
If ar(i, iRow) <> "" Then UboundSpecial = ar(i, iRow)
Next i
End Function
Function ausgabe()
Dim mysheet As Object
For i_sheet = 4 To bmwWbook.Sheets.Count
Set mysheet = bmwWbook.Sheets(i_sheet)
i_spalte = 0
With mysheet
If InStr(1, mysheet.Name, "CSFrt1exc", vbTextCompare) > 1 Then
i_spalte = 2
ElseIf InStr(1, mysheet.Name, "CSFrt2exc", vbTextCompare) > 1 Then
i_spalte = 3
ElseIf InStr(1, mysheet.Name, "CSFrt3exc", vbTextCompare) > 1 Then
i_spalte = 4
ElseIf InStr(1, mysheet.Name, "FfcCSFrt4", vbTextCompare) > 1 Then
i_spalte = 5
ElseIf InStr(1, mysheet.Name, "CSFrt5exc", vbTextCompare) > 1 Then
i_spalte = 6
End If
j = 0
For i = 0 To UBound(crash_names)
If UBound(crash_names(i, i_spalte)) > 0 Then
.Cells(j + 3, 20) = crash_names(i, i_spalte)(0)
.Cells(j + 3, 21) = crash_names(i, i_spalte)(1)
.Cells(j + 3, 22) = crash_names(i, i_spalte)(2)
j = j + 2
MsgBox crash_names(17, 2)
Else
.Cells(j + 3, 20) = crash_names(i, i_spalte)
.Cells(j + 3, 21) = crash_names(i, i_spalte)
.Cells(j + 3, 22) = crash_names(i, i_spalte)
j = j + 2
End If
Next i
End With
Next i_sheet
End Function
Bekomme immer eine Fehlermeldung bei der Bestimmung der Dimension.Public Sub Test()
Dim i As Integer
Dim Beispiel As Variant
'***************************************************************************************
Beispiel = Array(Array(1, 2), Array(4, 5, 6), Array(7, 8, 9, 10, 11))
For i = Lbound(Beispiel) To Ubound(Beispiel)
Debug.Print Ubound(Beispiel(i), 1)
Next i
'oder **********************************************************************************
Beispiel = Array(Range("A1:B10").Value2, Range("Z1:AB10").Value2, Range("G1:Y10").Value2)
For i = Lbound(Beispiel) To Ubound(Beispiel)
Debug.Print Ubound(Beispiel(i), 1), Ubound(Beispiel(i), 2)
Next i
End Sub
Gruß Tino