Vielleicht kann mir jemand helfen. In den zwei Makros steckt ein Wurm.
Das erste (
Sub SpeicherMirs())soll die Daten aus Range("A1:A10,B5,C1:C10")
in eine binar Datei speichern und das zweite (
Sub SchreibEsWiederRein())
in die gleiche Zellen wieder reinschreiben.Es scheint nicht so richtig zu
funktionieren. Weis jemand warum?
Bitte um Antwort
Peter
Sub SpeicherMirs()
Dim rngS As Range
Dim strPathAndFileName As String
Dim vntArray As Variant
Dim lngFN As Long
strPathAndFileName = "C:\Users\peter\Desktop\Microsoft Excel-Arbeitsblatt (neu)"
Set rngS = ActiveWorkbook.Worksheets("Tabelle1").Range("A1:A10,B5,C1:C10")
vntArray = rngS.Value
'File falls schon vorhanden entfernen
If Len(Dir(strPathAndFileName)) > 2 Then
Kill strPathAndFileName
End If
'File schreiben
lngFN = FreeFile
Open strPathAndFileName For Binary As lngFN
Put lngFN, 1, vntArray
Close lngFN
End Sub
------------------------------------------------------------------------------
Sub SchreibEsWiederRein()
Dim rngS As Range
Dim strPathAndFileName As String
Dim vntArray As Variant
Dim lngFN As Long
strPathAndFileName = "C:\Users\peter\Desktop\Microsoft Excel-Arbeitsblatt (neu)"
Set rngS = ActiveWorkbook.Worksheets("Tabelle1").Range("A1:A10,B5,C1:C10")
'File lesen
lngFN = FreeFile
Open strPathAndFileName For Binary As lngFN
vntArray = Space(LOF(lngFN))
Get lngFN, 1, vntArray
Close lngFN
'File ins Sheet schreiben
rngS.Value = vntArray
End Sub