Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. Public Sub splitUpRegexPattern()
  2. Dim regEx As New RegExp
  3. Dim strPattern As String
  4. Dim strInput As String
  5. Dim strReplace As String
  6. Dim Myrange As Range
  7.  
  8. Set Myrange = ActiveSheet.Range("B2:B4279")
  9.  
  10. For Each c In Myrange
  11. strPattern = "([A-Z]{2}/[A-Z]{2}/[A-Z][0-9]{2}/[a-z]{3}[0-9]{9}/)([0-9]{4})"
  12.  
  13. If strPattern <> "" Then
  14. strInput = c.Value
  15. strReplace = "$1"
  16.  
  17. With regEx
  18. .Global = True
  19. .MultiLine = True
  20. .IgnoreCase = False
  21. .Pattern = strPattern
  22. End With
  23.  
  24. If regEx.test(strInput) Then
  25. c.Offset(0, 1) = regEx.Replace(strInput, "$2")
  26. Else
  27. c.Offset(0, 1) = ""
  28. End If
  29. End If
  30. Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement