Public Sub TextToCol1()
Dim ws As Worksheet, lRow As Long
Set ws = ActiveWorkbook.Worksheets("LAVEXPORT")
ws.Range("B2:C3000").ClearContents
'ws.Range("A1").End(xlUp).TextToColumns , Semicolon:=True
With ws
lRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A1:A" & lRow).TextToColumns Semicolon:=True
'.Range("A2:A" & lRow).TextToColumns ConsecutiveDelimiter:=True, Semicolon:=True, Space:=True 'Option 1
'.Range("A2:B" & lRow).Value = Application.Trim(.Range("A2:B" & lRow)) 'Option 2
'.Cells(1, 2) = "KPI"
.Range("A1:N3000").AutoFilter
.Range("A1:N3000").VerticalAlignment = xlCenter
.Range("A1:N3000").HorizontalAlignment = xlCenter
'.Columns("A:N").AutoFit
.Range("A1:N3000").Columns.AutoFit
End With
End Sub
Public Sub SortingColumnsInRange()
' Selecting range
Range("A:N").Select
' Sort column C, after column N and after column P
Selection.Columns.Sort key1:=Columns("E"), Order1:=xlAscending, Key2:=Columns("F"), Order2:=xlAscending, Header:=xlYes
'Sheets.Add.Name = "AM"
'Sheets.Add = "PM"
'Sheets.Add After:=Worksheets("LAVEXPORT")
Sheets.Add(After:=Sheets("LAVEXPORT")).Name = "AM"
Sheets.Add(After:=Sheets("AM")).Name = "PM"
Sheets.Add(After:=Sheets("PM")).Name = "RON"
End Sub
Sub Test()
Dim rCrit As Range
With Sheets("LAVEXPORT").Range("A1").CurrentRegion
Set rCrit = .Offset(, .Columns.Count + 1).Resize(2, 1)
rCrit.Cells(2).Formula = "=LET(StartT,TIME(6,30,0),EndT,TIME(15,00,0),OR(AND(F2>=StartT,G2<=EndT,F2>=StartT,F2<=EndT),AND(G2="""",F2>=StartT,F2<=EndT),AND(F2<=StartT,G2>=StartT,G2<=EndT),AND(F2>EndT,G2>=StartT,G2<=EndT)))"
.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=rCrit, CopyToRange:=Sheets("AM").Range("A1"), Unique:=False
rCrit.ClearContents
End With
With Sheets("LAVEXPORT").Range("A1").CurrentRegion
Set rCrit = .Offset(, .Columns.Count + 1).Resize(2, 1)
rCrit.Cells(2).Formula = "=LET(StartT,TIME(15,01,0),EndT,TIME(23,00,0),OR(AND(G2>=StartT,G2<=EndT,F2>=StartT,F2<=EndT),AND(G2="""",F2>=StartT,F2<=EndT),AND(F2<=StartT,G2>=StartT,G2<=EndT),AND(F2>EndT,G2>=StartT,G2<=EndT)))"
'rCrit.Cells(2).Formula = "=LET(StartT,TIME(15,01,0),EndT,TIME(23,00,0),OR(AND(G2>=StartT,G2<=EndT,F2>=StartT,F2<=EndT),AND(G2="""",F2>=StartT,F2<=EndT),AND(F2>EndT,G2>=StartT,G2<=EndT)))"
.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=rCrit, CopyToRange:=Sheets("PM").Range("A1"), Unique:=False
rCrit.ClearContents
End With
With Sheets("LAVEXPORT").Range("A1").CurrentRegion
Set rCrit = .Offset(, .Columns.Count + 1).Resize(2, 1)
rCrit.Cells(2).Formula = "=LET(StartT,TIME(23,01,0),EndT,TIME(23,59,0),StartT2,TIME(00,00,0),EndT2,TIME(06,29,0),OR(AND(F2<=StartT, G2>=StartT, G2<=EndT, G2<>""""), AND(F2>=StartT, F2<=EndT, G2>=StartT, G2<=EndT, G2<>""""),AND(F2>=StartT, F2<=EndT, G2=""""),AND(F2>=StartT2, F2<=EndT2, G2=""""),AND(F2>=EndT2, G2>=StartT2, G2<=EndT2,G2<>""""), AND(F2>=StartT2, F2<=EndT2, G2>=StartT2, G2<=EndT2, G2<>""""), AND(F2>=EndT2, G2>=StartT2, G2<=EndT2, G2<>"""")))"
.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=rCrit, CopyToRange:=Sheets("RON").Range("A1"), Unique:=False
rCrit.ClearContents
End With
End Sub