使用下一个可用行将电子邮件地址string拆分成不同的列

我需要一些帮助,从电子表格中分离出一串电子邮件地址。 我有一个工作表,所以当你按下发送通知button时,代码将在一列中查找一个数字,如果该数字等于12它将从第4列中取出电子邮件地址并将其插入到“ “电子邮件的字段。 我想使用拆分functionlogging所有这些电子邮件地址,但我只收到第一个电子邮件地址,没有进一步的。 这是我的代码:

 Private Sub CommandButton1_Click() Dim OutApp As Object Dim OutMail As Object Dim strto As String, strcc As String, strbcc As String Dim strsub As String, strbody As String Dim emailRng As Range, cl As Range Dim sTo As String Dim sCC As String Dim x As Variant Dim Y As Variant Set emailRng = Worksheets("Sheet1").Range("D1:D500") For Each cl In emailRng If cl.Offset(, 68) = 1 Then sTo = sTo & ";" & cl.Value If cl.Offset(, 68) = 2 Then sCC = sCC & ";" & cl.Value Next cl sTo = Mid(sTo, 2) sBCC = Mid(sCC, 2) Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) strto = sTo strcc = sCC strbcc = "" strsub = "'NOTIFICATION' - " & Sheet9.Cells(1, 72).Value strbody = "<img src=Z:\Logo2.jpg width=624 height=74>" & _ "<font size=2 font face=Verdana color=black>" With OutMail .SentOnBehalfOfName = "" .to = strto .cc = strcc .bcc = strbcc .Subject = strsub .importance = 2 'You can add a file to the mail like this .HTMLBody = strbody .Display ' or use .Send End With Set OutMail = Nothing Set OutApp = Nothing x = Split(sTo, "") Y = Split(sCC, "") lrtag = Sheets("Log Sheet").Range("B" & Rows.Count).End(xlUp).Row Sheets("Log Sheet").Cells(lrtag + 1, "B").Value = "NOTIFICATION SENT" Sheets("Log Sheet").Cells(lrtag + 1, "C").Value = "DATE SENT" Sheets("Log Sheet").Cells(lrtag + 1, "D").Value = Now Sheets("Log Sheet").Cells(lrtag + 1, "E").Value = "NOTIFICATION SENT TO:" Sheets("Log Sheet").Cells(lrtag + 1, "F").Value =Application.Transpose(x) Sheets("HEADER").Select Unload Me End Sub 

我想我需要扩大这个陈述:

Sheets("Log Sheet").Cells(lrtag + 1, "F").Value =Application.Transpose(x)

如果将单维数组放在一行中,则不需要使用移调,但是您需要指定目标的全部范围:

 Sheets("Log Sheet").Cells(lrtag + 1, "F").Resize(1,ubound(x)+1).Value = x 

如果您希望数组垂直移动,则需要使用Transpose。