Last active
March 12, 2018 03:56
-
-
Save DuongAQ/387aa9bb3e677db56830a3f4843d26cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub test_RegExp() 'Sử dụng Regular Expression trong VBA | |
Dim RE As Object 'Khai báo biến Regular Expression để sử dụng | |
Dim strPattern As String 'Khai báo biến đại diện cho đoạn chuỗi text cần xử lý bởi RE | |
Dim matches As Object 'Kết quả sau khi thực hiện bởi RE | |
strPattern = "[ABCD]-hoc excel online" 'Thiết lập quy luật hiển thị dữ liệu | |
Set RE = CreateObject("VBScript.RegExp") 'Thiết lập Object cho Regular Expression | |
RE.Pattern = strPattern 'Xác định đoạn chuỗi sẽ xử lý bởi RE | |
RE.Global = True 'Lấy toàn bộ kết quả có được trong chuỗi | |
'Nếu RE.Global = False hoặc không sử dụng thì chỉ lấy được 1 kết quả đúng đầu tiên tìm được | |
Set matches = RE.Execute([A6]) 'Thiết lập kết quả khi sử dụng RE cho ô A6 | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment