Advertisement
BugFix

Untitled

Apr 25th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.72 KB | None | 0 0
  1. ' HIER EINE MULTILINE-VERSION
  2. ' NOCH NICHT BERÜCKSICHTIGT: evtl. "free.." in Zeile
  3.  
  4. Sub Swap_Coordinate() 'v1.0 coded by UEZ
  5.     Dim RegExsult As String
  6.     Dim allMatches As Object
  7.     Dim innerMatches As Object
  8.     Dim RegEx As Object 'New VBScript_RegExp_55.RegExp 'Tools -> References -> Microsoft VBScript Regular Expression 5.5
  9.     Set RegEx = CreateObject("VBScript.RegExp")
  10.     Dim iMultiLine As Integer
  11.     Dim iCurrent As Integer
  12.     RegExsult = ""
  13.     iCurrent = 0
  14.    
  15.     RegEx.Pattern = "(\n)"
  16.     RegEx.Global = True
  17.     RegEx.IgnoreCase = True
  18.     Set allMatches = RegEx.Execute(ActiveCell.Text)
  19.     iMultiLine = allMatches.Count
  20.    
  21.     If iMultiLine = 0 Then
  22.         RegEx.Pattern = "(.*) to (.*)"
  23.         Set allMatches = RegEx.Execute(ActiveCell.Text)
  24.         If allMatches.Count > 0 Then
  25.             RegExsult = allMatches.Item(0).subMatches.Item(1) & " to " & allMatches.Item(0).subMatches.Item(0) & " " & allMatches.Item(0).subMatches.Item(2)
  26.             ActiveCell.Value = RegExsult
  27.         End If
  28.     Else
  29.         RegEx.Pattern = "(.*)\n?"
  30.         Set allMatches = RegEx.Execute(ActiveCell.Text)
  31.         Do While iCurrent <= iMultiLine
  32.             RegEx.Pattern = "(.*) to (.*)"  ' wenn in MultiLine noch "free..." steht musst du das Pattern entsprechend anpassen
  33.             Set innerMatches = RegEx.Execute(allMatches.Item(iCurrent))
  34.             If RegExsult <> "" Then
  35.                 RegExsult = RegExsult & Chr(13) & Chr(10)
  36.             End If
  37.             RegExsult = RegExsult & innerMatches.Item(0).subMatches.Item(1) & " to " & innerMatches.Item(0).subMatches.Item(0)
  38.             iCurrent = iCurrent + 1
  39.         Loop
  40.         ActiveCell.Value = RegExsult
  41.     End If
  42.    
  43.     Set allMatches = Nothing
  44.     Set RegEx = Nothing
  45. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement