zellen auslesen und in array schreiben...
21.05.2004 13:58:18
loco
habe da ein problem.
und zwar arbeite ich mit vba und excel.
ich schreibe meine werte die aus einem array ausgelesen werden in die excel tabelle, dies funktioniert auch.
aber das rausschreiben aus der excel tabelle in mein array funktioniert nicht.
mein code:
Option Explicit
Dim myArray As Variant
Dim neuArray As Variant
Dim EA As Excel.Application
Dim WB As Excel.Workbook
Dim my_tabelle As Excel.Worksheet 'Tabellenblatt
Dim my_chart As Excel.Chart 'Diagrammblatt
Private Sub Form_Initialize()
'Prüfen, ob Excel bereits ausgeführt wird:
On Error Resume Next
Set EA = CreateObject("Excel.Application")
Set WB = EA.Workbooks.Add 'Arbeitsmappe hinzufügen
Set my_tabelle = Form1.Controls("Chart1").object.Sheets(2) 'Tabellenblatt
Set my_chart = Form1.Controls("Chart1").object.Sheets(1) 'Diagrammblatt
zum rein schreiben in tabelle:
Public Sub diagramm()
xRow = 2
For i = LBound(myArray) To UBound(myArray)
my_tabelle.Cells(xRow, ((i) Mod 2) + 1) = CDbl(myArray(i))
xRow = xRow + i Mod 2
Next
End Sub
dieser funktioniert einwandfrei.
und zum auslesen:
Private Sub Speichern_Click()
neuArray = myArray
xRow = 2
For i = LBound(neuArray) To UBound(neuArray)
'IN DER NÄHSTEN ZEILE KOMMT ES IMMER ZUR FEHLER MELDUNG!!!
neuArray(i)= CDbl(my_tabelle.Cells(xRow, ((i) Mod 2) + 1))
xRow = xRow + i Mod 2
Next
End Sub
und es kommt zur fehler meldung:
objektvariable oder with-blockvariable nicht festgelegt!
kann mir da jemand den fehler sagen bzw. helfen?
damit es funktioniert.
habe schon so viel versucht und es klappt nicht.
loco