如何添加一组值并一次输出整个组?

在VBA中,如何添加一组值并一次输出整个组?

基本上我正在寻找像这样的东西:

Todays_Date = 9/1/15 If Compliance_Date1 = Todays_Date then Collection.add “Compliance Date 1” If Compliance_Date2 = Todays_Date then Collection.add “Compliance Date 2” If Compliance_Date3 = Todays_Date then Collection.add “Compliance Date 3” Output Entire Collection: Compliance Date 1 Compliance Date 2 Compliance Date 3 

如果你不知道如何使用集合,你可能希望保留一个string。

 Dim strDateList as string If Compliance_Date1 = Todays_Date then strDateList = strDateList & “Compliance Date 1” & vbCrLf If Compliance_Date2 = Todays_Date then strDateList = strDateList & “Compliance Date 2” & vbCrLf If Compliance_Date3 = Todays_Date then strDateList = strDateList & “Compliance Date 3” & vbCrLf 

然后“输出”

 msgbox strDateList