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 根据起始日期计算到期日_第1张图片

你可能感兴趣的:(excel,vba,存储,excel技巧)