ich kämpfe leider noch immer mit dem Beispiel von dieser Seite:
http://www.online-excel.de/excel/singsel_vba.php?f=137
Und zwar mit folgender Methode:
Private Function AusgabePerGetRows(DasRecordSet As Object, StartAusgabe As Range) As Long
' Peter Haserodt 2007
Dim vX As Variant, iRowCount As Long, iColCount As Long
On Error GoTo Fehler
StartAusgabe.CurrentRegion.Clear
vX = WorksheetFunction.Transpose(DasRecordSet.getrows)
iRowCount = UBound(vX, 1)
On Error Resume Next
iColCount = UBound(vX, 2)
On Error GoTo Fehler
If iColCount = 0 Then
With StartAusgabe.Parent
.Range(.Cells(StartAusgabe.Row, StartAusgabe.Column), _
.Cells(StartAusgabe.Row, StartAusgabe.Column + iRowCount - 1)).Value = vX
End With
AusgabePerGetRows = 1
Else
With StartAusgabe.Parent
.Range(.Cells(StartAusgabe.Row, StartAusgabe.Column), _
.Cells(StartAusgabe.Row + iRowCount - 1, StartAusgabe.Column + iColCount - 1)).Value = vX
End With
AusgabePerGetRows = iRowCount + 1
End If
Exit Function
Fehler:
AusgabePerGetRows = 0
End Function
Wenn ich das mal mit März durchspiele -> dann habe ich doch folgendes:
vX = WorksheetFunction.Transpose((2,4)) //Das Recordset das ich an die Funktion übergebe hat ja 2 Spalten und 4 Zeilen
vx(4,2) //durch die Transpose Funktion transponiere ich das Array in 4 Zeilen und 2 Spalten
iRowCount = 4
iColCount = 2
Range(Cells(2,2),Cells(5,3)).Value = vX
AusgabePerGetRows = 5
-> Ist das so korrekt interpretiert?
-> Warum er bei dieser Funktion jedoch als Retur iRowCount + 1 macht, verstehe ich nicht? :(
Wenn ich jetzt dem Beispiel einmal Dezember mit Wert 13 hinzufüge würde das Beispiel wie folgt aussehen:
vX = WorksheetFunction.Transpose((2,1)) //das Recordset besteht aus 2 Spalten und 1 Zeile
vX(1,2) //durch Transpose wird das wieder umgedreht
iRowCount = 1
iColCount = 2
->Aber jetzt geht er ja in den If iColCount = 0 Then Zweig hinein, obwohl iColCount nach meinem Verständnis 2 und nicht 0 ist.
Weiss jemand wie man das Beispiel richtig durchspielt? :(
liebe grüsse
pat