Code for macro
Sub GetData()
Dim M1, M2, M3
Dim LR
LR = Range("A" & Rows.Count).End(xlUp).Row
M1 = Filter(Evaluate("Transpose(IF(ISnumber(Search(""VIA at xy"",A1:A" & LR & ")),TRIM(substitute(A1:A" & LR & ",""VIA at xy "","""")),False))"), False, False)
Range("B2:B" & UBound(M1) + 2) = WorksheetFunction.Transpose(M1)
[C2] = 1
[C3] = 2
Range("C2:C3").AutoFill Destination:=Range("C2:C" & UBound(M1) + 2)
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add2 Key:=Range( _
"B2:B" & UBound(M1) + 2), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveSheet.Sort
.SetRange Range("B2:C" & UBound(M1) + 2)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
StRo = 1
For T = 2 To UBound(M1) + 2
If Range("B" & T + 1) <> Range("B" & T) Then
Range("D" & T) = T - StRo
StRo = T
End If
Next T
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add2 Key:=Range( _
"C2:C" & UBound(M1) + 2), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveSheet.Sort
.SetRange Range("B2:D" & UBound(M1) + 2)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
M2 = Filter(Evaluate("Transpose(IF(D2:D" & UBound(M1) + 2 & "=2,B2:B" & UBound(M1) + 2 & ",False))"), False, False)
M3 = Filter(Evaluate("Transpose(IF(D2:D" & UBound(M1) + 3 & "=3,B2:B" & UBound(M1) + 2 & ",False))"), False, False)
Range("E2:E" & UBound(M2) + 2) = WorksheetFunction.Transpose(M2)
Range("F2:F" & UBound(M3) + 2) = WorksheetFunction.Transpose(M3)
Range("c2").EntireColumn.Delete
End Sub
Bookmarks