一个公式排列月份只有2个date

A1: I have 1/1/13 A2: I have 7/25/13 

在A3中如何使用一个公式,输出如下所示:

 1/31/13,2/28/13,3/31/13,4/30/13,5/31/13,6/30/13,7/31,13 

即。 在一个单元格中,一个公式给我所有的月份结束date。

没有代码请。

把它放在一个模块中:

 Function myFormula(startDate, endDate) On Error GoTo err Dim result As String result = "" noOfMonths = DateDiff("m", startDate, endDate) For i = 1 To noOfMonths + 1 Dim myDate As Date myDate = DateAdd("d", Day(startDate) - 1, startDate) myDate = DateAdd("m", i, myDate) myDate = DateAdd("d", -1, myDate) result = result & Format(myDate, "m\/d\/yy") If i <= noOfMonths Then result = result & "," Next i myFormula = result ex: Exit Function err: MsgBox (err.Number & err.Description) myFormula = "Error" Resume ex End Function 

这在A3: = myFormula(A1; A2)