excel 根据起始日期计算到期日

B1内存储着文本格式的日期20111201
计算三个月后的到期日
=EDATE(TEXT(B1,"0000-00-00"),3)
格式化日期
=TEXT(A2,"yyyymmd")

VBA 批量解决

Private Sub CommandButton1_Click()
Dim i As Integer
For i = 1 To 9
If Sheet1.Cells(i, 2) <> "" Then
Sheet1.Cells(i, 3) = Sheet1.Application.WorksheetFunction.EDate(Sheet1.Application.WorksheetFunction.Text(Sheet1.Cells(i, 2), "0000-00-00"), 3)
End If
Next i
End Sub


你可能感兴趣的:(Excel,存储,VBA)