Sub ReadAbpm50FileNewFF() ' ' Einfaches Macro zum Einlesen einer Messwertdatei des ABPM50 ' Source: http://www.alexmumm.de/pgAbpm50_de.htm ' fName = Application.GetOpenFilename("ABPM50 Dateien (*.awp), *.awp") If fName = "" Or fName = False Then MsgBox "Dateiauswahl - Abbruch" Exit Sub End If Columns("A:G").Select ' Achtung! Selection.ClearContents ' Hier wird beim Lauf des Macros geloescht! i = 1 Cells(i, 1).Value = "Nummer" ' Spaltenueberschriften Cells(i, 2).Value = "Datum" Cells(i, 3).Value = "Zeit" Cells(i, 4).Value = "Sys" Cells(i, 5).Value = "Dia" Cells(i, 6).Value = "MAP" Cells(i, 7).Value = "HR" i = i + 1 Open fName For Input As #1 ' Datei zum Lesen oeffnen Do Until EOF(1) ' So lange bis Dateiende erreicht: Line Input #1, txt ' Zeile aus Datei lesen If InStr(txt, "=") Then ' Zeile mit Gleichzeichen? txtL = Left(txt, InStr(txt, "=") - 1) ' Text links vom Gleichzeichen txtR = Right(txt, Len(txt) - InStr(txt, "=")) ' Text rechts vom Gleichzeichen If IsNumeric(txtL) Then ' Zahl links? Dann Messung gefunden! Cells(i, 1).EntireRow.Clear ' Zeile in Tabelle loeschen Cells(i, 1).Value = Val(txtL) ' Nummer 'Cells(i, 2).Value = Val("&H" + Mid(txtR, 1, 4)) ' Minuten seit Start (mit Hex-Dez-Umwandlung) 'Cells(i, 2).NumberFormat = "dd.mm.YYYY" Cells(i, 2).Value = CDate((Val("&H" + Mid(txtR, 7, 2)) & "." & (Val("&H" + Mid(txtR, 5, 2))) & "." & (Val("&H" + Mid(txtR, 1, 4))))) 'Cells(i, 2).Value = CStr((Val("&H" + Mid(txtR, 7, 2)))) 'Cells(i, 2).NumberFormat = "dd.mm.YYYY" Cells(i, 3).Value = CDate((Val("&H" + Mid(txtR, 9, 2)) & ":" & (Val("&H" + Mid(txtR, 11, 2))))) Cells(i, 3).NumberFormat = "hh:mm" Cells(i, 4).Value = Val("&H" + Mid(txtR, 17, 2)) ' Sys (mit Hex-Dez-Umwandlung) Cells(i, 5).Value = Val("&H" + Mid(txtR, 21, 2)) ' Dia (mit Hex-Dez-Umwandlung) Cells(i, 6).Value = Val("&H" + Mid(txtR, 25, 2)) ' MAP (mit Hex-Dez-Umwandlung) Cells(i, 7).Value = Val("&H" + Mid(txtR, 29, 2)) ' HR (mit Hex-Dez-Umwandlung) i = i + 1 'ElseIf txtL = "MinBegin" Then ' Start Minuten gefunden ' minBegin = txtR ' Merken 'ElseIf txtL = "HourBegin" Then ' Start Stunden gefunden ' hourBegin = txtR ' Merken 'ElseIf txtL = "DayBegin" Then ' Start Tag gefunden ' dayBegin = txtR ' Merken 'ElseIf txtL = "MonthBegin" Then ' Start Monat gefunden ' monthBegin = txtR ' Merken 'ElseIf txtL = "YearBegin" Then ' Start Jahr gefunden ' yearBegin = txtR ' Merken End If End If Loop Close ' StartDate = yearBegin + "-" + monthBegin + "-" + dayBegin + " " + hourBegin + ":" + minBegin ' If IsDate(StartDate) = False Then ' Gefundenes Startdatum pruefen ' MsgBox "Abbruch - Kein Startdatum" ' Exit Sub ' End If ' While i > 2 ' Tabelle rueckwaerts durchlaufen und Minuten in echtes Datum umwandeln ' i = i - 1 ' minutes = Cells(i, 2).Value ' Cells(i, 2).Value = CDate(StartDate) + minutes / 24 / 60 ' Cells(i, 2).NumberFormat = "DD.MM.YYYY hh:mm" ' Wend Columns("A:G").Select ' Vorsichtshalber sortieren Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, Orientation:=xlTopToBottom Range("A1").Select End Sub