Hugo, ну у тебя как то проще выглядит=) просто я твоё сообщение поздно прочитал=)
вот конечный вариант, ещё листинг покажу
EducatedFool, я тут частенько ищу) да и как бы самому всё таки надо работать, а то как то нехорошо выходит.
Sub neww()
Application.ScreenUpdating = 0
Const n = 15
Dim a!, time!, b As String, i!, j!, iFile As String, strin() As String, temp As String, temp2() As String
iFile = Application.GetOpenFilename("Текстовый документ, *.txt", , "Выбрать документ")
If Dir(iFile) = "" Then Exit Sub
j = j + 1
Do While ThisWorkbook.Sheets("sheet2").Cells(j, 1) <> ""
j = j + 1
Loop
ThisWorkbook.Sheets("sheet2").Cells(j, 1) = iFile 'если не надо выводить название файла удали эту строку
j = j + 1 'и эту
i = 2
'Set xlsa = Workbooks.Open(Filename:=iFile, ReadOnly:=True)
Open iFile For Input As #1
'b = ts.readline 'xlsa.Sheets("shhet1").Cells(1, 4)
Line Input #1, b
strin = Split(b, ",")
temp2 = Split(strin(3), "\")
strin(3) = temp2(1)
ThisWorkbook.Sheets("sheet2").Cells(j, 1) = strin(3) 'xlsa.Sheets("shhet1").Cells(1, 4)
strin(1) = datetostr(strin(1))
ThisWorkbook.Sheets("sheet2").Cells(j, 2) = strin(1) 'xlsa.Sheets("shhet1").Cells(1, 2)
strin(2) = timetostr(strin(2))
ThisWorkbook.Sheets("sheet2").Cells(j, 3) = strin(2) 'xlsa.Sheets("shhet1").Cells(1, 3)
ThisWorkbook.Sheets("sheet2").Cells(j, 4) = strin(2) 'xlsa.Sheets("shhet1").Cells(1, 3)
Do While Not EOF(1) 'xlsa.Sheets("shhet1").Cells(i, 1) <> ""
temp = strin(3)
Line Input #1, b
strin = Split(b, ",")
temp2 = Split(strin(3), "\")
strin(3) = temp2(1)
If temp <> strin(3) Then 'xlsa.Sheets("shhet1").Cells(i, 4) Then
ThisWorkbook.Sheets("sheet2").Cells(j, 4) = del_x(ThisWorkbook.Sheets("sheet2").Cells(j, 4))
ThisWorkbook.Sheets("sheet2").Cells(j, 3) = del_x(ThisWorkbook.Sheets("sheet2").Cells(j, 3))
j = j + 1
ThisWorkbook.Sheets("sheet2").Cells(j, 1) = strin(3) 'xlsa.Sheets("shhet1").Cells(i, 4)
strin(1) = datetostr(strin(1))
ThisWorkbook.Sheets("sheet2").Cells(j, 2) = strin(1) 'xlsa.Sheets("shhet1").Cells(i, 2)
strin(2) = timetostr(strin(2))
ThisWorkbook.Sheets("sheet2").Cells(j, 3) = strin(2) 'xlsa.Sheets("shhet1").Cells(i, 3)
ThisWorkbook.Sheets("sheet2").Cells(j, 4) = strin(2) 'xlsa.Sheets("shhet1").Cells(i, 3)
b = strin(3) 'xlsa.Sheets("shhet1").Cells(i, 4)
Else
a = strin(2) 'xlsa.Sheets("shhet1").Cells(i, 3)
xx = ThisWorkbook.Sheets("sheet2").Cells(j, 3)
time = strtotime(ThisWorkbook.Sheets("sheet2").Cells(j, 3))
If a < time Then
ThisWorkbook.Sheets("sheet2").Cells(j, 3) = timetostr(a)
Else
time = strtotime(ThisWorkbook.Sheets("sheet2").Cells(j, 4))
If a > time Then ThisWorkbook.Sheets("sheet2").Cells(j, 4) = timetostr(a)
End If
End If
i = i + 1
Loop
ThisWorkbook.Sheets("sheet2").Cells(j, 4) = del_x(ThisWorkbook.Sheets("sheet2").Cells(j, 4))
ThisWorkbook.Sheets("sheet2").Cells(j, 3) = del_x(ThisWorkbook.Sheets("sheet2").Cells(j, 3))
'ThisWorkbook.Sheets("sheet2").Cells(j, 4) = strin(2) 'xlsa.Sheets("shhet1").Cells(i - 1, 3)
'xlsa.Close
Close #1
Application.ScreenUpdating = 1
End Sub
Function datetostr(a As String)
Dim temp As Long, temp2 As String
temp = CLng(a)
temp2 = temp Mod 100
temp = temp \ 100
temp2 = temp2 & "." & temp Mod 100
temp = temp \ 100
temp2 = temp2 & "." & temp Mod 100
datetostr = temp2
End Function
Function timetostr(ByVal xxx As String)
Dim temp As Long, temp2 As String
temp = CLng(xxx)
If temp Mod 100 > 9 Then
temp2 = temp Mod 100
Else
If temp Mod 100 = 0 Then
temp2 = "00"
Else
temp2 = "0" & temp Mod 100
End If
End If
temp = temp \ 100
If temp Mod 100 > 9 Then
temp2 = temp Mod 100 & ":" & temp2
Else
If temp Mod 100 = 0 Then
temp2 = "00:" & temp2
Else
temp2 = "0" & temp Mod 100 & ":" & temp2
End If
End If
temp = temp \ 100
If temp Mod 100 > 9 Then
temp2 = temp Mod 100 & ":" & temp2
Else
If temp Mod 100 = 0 Then
temp2 = "00:" & temp2
Else
temp2 = "0" & temp Mod 100 & ":" & temp2
End If
End If
timetostr = "x:" & temp2
End Function
Function strtotime(ByVal a As String)
Dim temp2 As String, temp() As String
temp = Split(a, ":")
temp2 = temp(1) & temp(2) & temp(3)
strtotime = temp2
End Function
Function del_x(sas As String)
Dim mas() As String
mas = Split(sas, ":")
del_x = mas(1) & ":" & mas(2) & ":" & mas(3)
End Function