Sub
ExportCSV()
Dim
Blatt
As
Worksheet, Jahr
As
Long
, BeginnSZ
As
Date
, BeginnWZ
As
Date
, sz
As
Boolean
Dim
Pfad
As
String
, Zeitstrng
As
String
, Datum
As
Date
, Zeit
As
Date
, p
As
Boolean
Set
Blatt = Sheets(
"Tabelle1"
)
Pfad = ThisWorkbook.Path &
"\" & Left(ThisWorkbook.Name, InStr(ThisWorkbook.Name, "
.
")) & "
csv"
lzei = Cells(Rows.Count, 1).
End
(xlUp).Row
Open Pfad
For
Output
As
#1
For
z = 2
To
lzei
Datum = Blatt.Cells(z, 1)
Jahr = Year(Datum)
BeginnSZ = DateSerial(Jahr, 3, 31) - Weekday(DateSerial(Jahr, 3, 31)) + 1
BeginnWZ = DateSerial(Jahr, 10, 31) - Weekday(DateSerial(Jahr, 10, 31)) + 1
For
s = 2
To
97
Zeit = Blatt.Cells(1, s)
If
Datum = BeginnSZ
And
CStr
(Zeit) =
"02:00:00"
Then
s = s + 4
Zeit = Blatt.Cells(1, s)
ElseIf
Datum = BeginnWZ
And
CStr
(Zeit) =
"03:00:00"
And
p =
False
Then
s = s - 4
Zeit = Blatt.Cells(1, s)
p =
True
End
If
If
Datum + Zeit >= BeginnSZ + TimeValue(
"03:00:00"
)
And
Datum + Zeit < BeginnWZ + TimeValue(
"03:00:00"
)
And
p =
False
Then
sz =
True
Else
sz =
False
Print #1, Format(Datum + Zeit,
"yyyy-mm-dd hh:nn:ss"
) & IIf(sz,
"+02:00"
,
"+01:00"
), Cells(z, s)
Next
s
Next
z
Close #1
MsgBox
"Die Datei "
& Pfad &
" wurde erzeugt."
End
Sub