- Katılım
- 19 Kasım 2021
- Mesajlar
- 80
- Excel Vers. ve Dili
- Excel 2016
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Option Explicit
Option Compare Text
Function SORT_BY_TEXT(Rng As String)
Dim My_Text As String, My_Data As Object
Dim Text As Object, Sorting_List As Variant
Application.Volatile True
My_Text = Replace(Replace(Replace(Rng, " : ", ":"), " :", ":"), ": ", ":")
My_Text = Replace(Replace(Replace(My_Text, " / ", "/"), " /", "/"), "/ ", "/")
ReDim Sorting_List(1 To 4)
With CreateObject("VBScript.Regexp")
.Pattern = "(\S+ MAH.)|(\S+ SOK.)|(\S+ CAD.)|(NO:\d+\/\d+)|(\S+)"
.Global = True
.IgnoreCase = True
Set My_Data = .Execute(My_Text)
For Each Text In My_Data
If InStr(1, Text.Value, "MAH.") > 0 Then
Sorting_List(1) = Text.Value
ElseIf InStr(1, Text.Value, "CAD.") > 0 Or InStr(1, Text.Value, "SOK.") > 0 Then
Sorting_List(2) = Text.Value
ElseIf InStr(1, Text.Value, "NO:") > 0 Then
Sorting_List(3) = Text.Value
ElseIf InStr(1, Text.Value, "/") > 0 Then
Sorting_List(4) = Text.Value
End If
Next
Set My_Data = Nothing
End With
SORT_BY_TEXT = Join(Sorting_List, " ")
Erase Sorting_List
End Function