我正在为预算表制作VBA宏。当它将数据复制到单元格B30时,我希望它查看单元格,如果单元格中有数据移动到B31,依此类推。但是,当它到达单元格B41时,我希望它抛出并出现错误消息。我将如何编写此代码?
Sheets("Budget with Revenue 2017-Test").Select
Range("B18:I18").Select
Application.CutCopyMode = False
Selection.Copy
Range("B22").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("Table2940[[Sum of Revenue]:[Sum of Savings]]").Select
Application.CutCopyMode = False
Selection.Copy
Range("B30").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("B21:I22").Select
Range("I21").Activate
Application.CutCopyMode = False
Selection.ClearContents
Range("B14:H14").Select
Range("H14").Activate
Selection.ClearContents
Range("J2:J3").Select
Selection.ClearContents
Range("G2").Select
Selection.ClearContents