我想将多行的值分配给 VBA 示例中的变量:
Dim campaign_date As Variant
campaign_date = "ABC vs. XYZ Report
n Weeks Comparison
ABC - January 30, 2011 - February 26, 2011
XYZ - October 31, 2010 - November 27, 2010"
以上代码无效。请为同样的方法提出一个好的方法
答案 0 :(得分:2)
Dim campaign_date As Variant
campaign_date = "ABC vs. XYZ Report " & vbCrLf & _
"n Weeks Comparison" & vbCrLf & _
"ABC - January 30, 2011 - February 26, 2011 " & vbCrLf & _
"XYZ - October 31, 2010 - November 27, 2010"
下划线_
是行继续符,&符号&
连接字符串,关键字vbCrLf
是换行符(Cr =回车符,Lf =换行符)。< / p>