Это должно делать то, что вы хотите. Я использовал ответ Portland Runner на этот пост , чтобы установить ссылку на RegEx в своем VBA и узнать синтаксис для него. Вместо каждого цикла я вычисляю последнюю строку столбца A и использую цикл for с таким количеством итераций. Переменная i установлена в 2, чтобы пропустить заголовок в строке 1.
Sub SplitCol()
'Set references to active workbook and sheet
Dim wb As Workbook
Dim ws As Worksheet
Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
'Create Regular Expression object and set up options
Dim regEx As New RegExp
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
'[0-9] means that regex will check for all digits
'{6} means that a minimum of 6 consecutive chars must meet the [0-9] criteria
.pattern = "[0-9]{6}"
End With
'All .Methods and .Properties will belong to ws object due to With
With ws
'Determine how many rows to loop through
Dim lastRowA As Long
lastRowA = .Range("A" & .Rows.Count).End(xlUp).Row
'Main loop
Dim i As Integer
For i = 2 To lastRowA
'Make sure there is a value in the cell or code will error out
If Cells(i, 1).Value <> "" Then
'Test regex of cell
If regEx.Test(Split(Cells(i, 1).Value, " ")(0)) Then
'If regex was true, set 3rd column (C) equal to numbers and
'4th column (D) equal everything else
Cells(i, 3).Value = Split(Cells(i, 1).Value, " ")(0)
Cells(i, 4).Value = Split(Cells(i, 1).Value, " ")(1)
End If
End If
Next
End With
'Release regEx object to reduce memory usage
Set regEx = Nothing
End Sub
Последняя граница части MIME должна быть обозначена путем добавления двух тире:
MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------boundary" --------------boundary ... --------------boundary ... --------------boundary--
Больше чтения здесь: RFC1341 / 7.2 Многослойный Тип контента