完全新手,我对VBA术语或其他方面一无所知,并在搜索网页和试错的情况下完成了以下内容。我想要完成的是允许用户在输入框中输入多行,从每行中获取数据并让每行显示在电子邮件正文中。目前,如果用户在输入框中输入3,4,则电子邮件仅包含来自第4行的数据,因为它是最后一个“i”。我想要包含来自两行的数据。
'Complete review button
Sub Macro4()
If MsgBox("Was information added to the report today?", vbYesNo) = vbYes Then
Macro5
Else
Macro6
End If
End Sub
'Complete review button if yes
Sub Macro5()
Dim vSplit() As String
Dim myRowNumber As String
Dim i As Long
'Dim sMsgIntro As String
Dim sMsgVari As String
myRowNumber = InputBox("Enter Row Number:")
If myRowNumber = vbNullString Then End
vSplit = Split(myRowNumber, ",")
For i = LBound(vSplit) To UBound(vSplit)
Debug.Print vSplit(i)
'sMsgIntro = "Today's review is complete and the following information was added to the report: " & vbNewLine & vbNewLine & m & vbNewLine & vbNewLine
sMsgVari = "Row Number: " & (vSplit(i)) & vbNewLine & (Cells(vSplit(i), 1)) & ", text " & (Cells(vSplit(i), 2)) & ", more text " & (Cells(vSplit(i), 6)) & ", more text " & (Cells(vSplit(i), 3)) & " more text " & (Cells(vSplit(i), 7)) & " more text."
Next i
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "me@gmail.com"
.CC = ""
.BCC = ""
.Subject = ""
.Body = "Today's review is complete and the following information was added to the report: " & vbNewLine & vbNewLine & _
sMsgVari
.Close olSave
End With
Set OutMail = Nothing
Set OutApp = Nothing