According to your post #15 attachment a VBA demonstration for a starting point to paste only to the Sheet2 (all) worksheet module :
PHP Code:
Sub Demo1() Const L = #10/2/2022 10:17:00 AM#, U = #10/2/2022 10:27:00 AM# Dim C$, F%, V C = ThisWorkbook.Path & "\20220210_103831.csv": If Dir(C) = "" Then Beep: Exit Sub F = FreeFile UsedRange.Clear Open C For Input As #F V = Split(Input(LOF(F), #F), vbCrLf) Close #F Application.ScreenUpdating = False With [A1].Resize(UBound(V) + 1) .Value2 = Application.Transpose(V) .TextToColumns , 1, xlTextQualifierNone, , , True, , , , , , "." End With With UsedRange.Columns .Item(1).AutoFilter 1, "<" & Format(L, [A2].NumberFormat), 2, ">=" & Format(U, [A2].NumberFormat) If Application.Subtotal(103, .Item(1)) > 1 Then .Offset(1).EntireRow.Delete .AutoFilter ' .AutoFit End With Application.ScreenUpdating = True End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » ! ◄ ◄
According to your post #15 attachment a VBA demonstration for a starting point to paste only to the Sheet2 (all) worksheet module :
PHP Code:
Sub Demo1() Const L = #10/2/2022 10:17:00 AM#, U = #10/2/2022 10:27:00 AM# Dim C$, F%, V C = ThisWorkbook.Path & "\20220210_103831.csv": If Dir(C) = "" Then Beep: Exit Sub F = FreeFile UsedRange.Clear Open C For Input As #F V = Split(Input(LOF(F), #F), vbCrLf) Close #F Application.ScreenUpdating = False With [A1].Resize(UBound(V) + 1) .Value2 = Application.Transpose(V) .TextToColumns , 1, xlTextQualifierNone, , , True, , , , , , "." End With With UsedRange.Columns .Item(1).AutoFilter 1, "<" & Format(L, [A2].NumberFormat), 2, ">=" & Format(U, [A2].NumberFormat) If Application.Subtotal(103, .Item(1)) > 1 Then .Offset(1).EntireRow.Delete .AutoFilter ' .AutoFit End With Application.ScreenUpdating = True End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » ! ◄ ◄
Thanks, but in may sheet still shows 02-10 instead of 10-02
So your bad 'cause you misread my post #14 as my demonstration reproduces exactly your attachment expected result workbook !
Ok, maybe my english is not enough, but I copied your code into new worksheet and result is - date is incorrect(day swapped with month). What I do bad?
Your post #15 attachment does not have the exact expected result workbook as requested in my post #14 …
Ok.
Do you like wasting time? Just read post #1 and you should know that result I want to reach is "For example date 10-02-2022 02:09:26 is shown in excel cell as 02-10-2022 02:09:26
How to fix this problem?"
Yes, my bad, in the file "result" is wrong date format
Next time you will create a thread you should be more accurate in your initial post
as is it so difficult to indicate the text file date format like to attach the exact expected result ?‼
As a reminder VBA CDate function well works only if the Windows Regional Settings are the same than the date format used within the csv file …
So according to the post #15 bad attachment, according to Excel basics & VBA help,
a VBA demonstration for starters to paste only to the Sheet2 (all) worksheet module :
PHP Code:
Sub Demo2() Dim S$, L As Date, U As Date, F%, V, R&, D As Date S = ThisWorkbook.Path & "\20220210_103831.csv": If Dir(S) = "" Then Beep: Exit Sub L = DateSerial(2022, 2, 10) + TimeValue("10:17") U = DateSerial(2022, 2, 10) + TimeValue("10:27") F = FreeFile UsedRange.Clear Open S For Input As #F V = Split(Input(LOF(F), #F), vbCrLf) Close #F For R = 1 To UBound(V) If V(R) > "" Then D = DateSerial(Mid(V(R), 7, 4), Mid(V(R), 4, 2), Left(V(R), 2)) + TimeValue(Mid(V(R), 13, 8)) If D < L Or D >= U Then V(R) = False Else Mid(V(R), 1, 5) = Format$(D, "mm-dd") Else V(R) = False End If Next V = Filter(V, False, False) With [A1].Resize(UBound(V) + 1) .Value2 = Application.Transpose(V) .TextToColumns , 1, xlTextQualifierNone, , , True, , , , , , "." End With End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » ! ◄ ◄
Bookmarks