trong file excel, nhấn alt + F11 để mở vba, tạo module mới và cho code này vào:
'----------------
Function Sep(txt As String, flg As Boolean) As String
With CreateObject("VBScript.RegExp")
.Pattern = IIf(flg = True, "\d+", "\D+")
.Global = True
Sep = .Replace(txt, "")
End With
End Function
'---------------
Đọc kĩ hướng dẫn sử dụng trước khi dùng:
Giả sử A1 = KHD33H4319
Công thức ở A2: =sep(A1, 0) =>> kết quả: 334319
Công thức ở A3: =sep(A1,1) =>> kết quả: KHDH