Sub TEST()
Dim xArea As Range, xRow As Range, M1%, M2%
Set xArea = [C2:L13]
M1 = Month(Date)
For Each xRow In xArea.Rows
M2 = Val(xRow.Cells(1, 0))
If M1 - M2 = 1 Then
If xRow(2).HasFormula Then Exit Sub
If xRow.HasFormula Then
xRow.Copy xRow(2)
Else
MsgBox xRow.Cells(1, 0) & "無公式或公式不齊全!! ": Exit Sub '同一列儲存格都有公式才會複製
End If
End If
If M2 < M1 Then xRow = xRow.Value
Next
End Sub作者: msmplay 時間: 2017-5-1 16:46