将一系列单元格转换为字符串的最佳方法是什么?我有一个函数只接受一个字符串作为输入所以我需要将范围转换为字符串,同时保留尽可能多的格式(即它需要看起来像一个表或列表,而不仅仅是一串字符) .我尝试过使用CStr(),以及从一个范围转换为一个数组然后转换为一个字符串,但我只是得到了错误.
编辑:代码尝试
Dim email_answer As Integer
email_answer = MsgBox("Do you want to be emailled a copy of this schedule?", vbYesNo)
If email_answer = vbYes Then
Dim wb As Workbook
Dim to_send As Range
to_send = Range("D3", "D10")
If Val(Application.Version) < 14 Then Exit Sub
Set wb = ActiveWorkbook
With wb
MailFromMacWithMail body content:=CStr(to_send), _
mailsubject:="Schedule", _
toaddress:="email address", _
ccaddress:="", _
bccaddress:="", _
attachment:=.FullName, _
displaymail:=False
End With
Set wb = Nothing
End If
Run Code Online (Sandbox Code Playgroud)