希望将以下代码合并/合并到一个模块/脚本中。 "擦除"应首先执行脚本,然后执行" MoveData"会运行:
Sub Erase()
'
' Erase Macro
' Erase Data
'
rspn = MsgBox("Are you Sure?", vbYesNo)
If rspn = vbNo Then Exit Sub
'code
'
ActiveWindow.SmallScroll Down:=-27
Range("N3:Y152").Select
Selection.ClearContents
Range("N3").Select
Range("N3:Y152").Interior.Color = xlNone
End Sub
Sub MoveData()
Dim vals As Range, val As Range, colOffset As Integer
Set vals = Range("K3:K" & Range("K3").End(xlDown).Row)
For Each val In vals
If val > 0 Then
colOffset = VBA.Month(val.Offset(0, 16))
val.Offset(0, colOffset) = val
val.Offset(0, colOffset + 1) = val.Offset(0, 1)
val.Offset(0, colOffset + 2) = val.Offset(0, 2)
End If
Next val
MsgBox "Operation Completed"
End Sub
答案 0 :(得分:2)
删除“Sub Erase()”
末尾的“End Sub”删除“Sub MoveData()”
将名称从Erase()更改为其他名称。