尝试类似下面的代码(我使用DateAdd
函数将1个月添加到当前日期值)
Sub IncreaseMonth() Dim dDate As Date Dim NumberofTasks As Long Dim x As Long With Worksheets("Dashboard") ' I suspect you want to get the last row with data in Column C NumberofTasks = .Cells(.Rows.Count, "C").End(xlUp).Row For x = 1 To NumberofTasks If IsDate(.Range("C" & x).Value) Then '<-- check if current cell at Column C is Date .Range("C" & x).Value = DateAdd("m", 1, .Range("C" & x).Value) '<-- add 1 Month to current date in Column c, use DateAdd function End If Next x End With End Sub