sub或函数未定义错误?

时间:2015-08-04 04:34:03

标签: vba excel-vba error-handling copy-paste excel

任何人都可以查看这段代码,为什么它会给我错误?

Sub orgnize()
    Dim Rng As Range

    Application.ScreenUpdating = True
    Workbook("kob1").Activate
    Worksheets(1).Activate
    Worksheets(1).Range("a1,b1,c1,d1,e1,f1,g1,j1,k1,l1,n1,o1,p1").EntireColumn.Delete
    Range("A2").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Set Rng = Selection.SpecialCells(xlCellTypeVisible)
    Rng.Copy
    Sheets(2).Range("a1").PasteSpecial xlPasteValues
    Workbooks("kob1").Close SaveChanges:=False
End Sub

1 个答案:

答案 0 :(得分:2)

此行显示错误:

Workbook("kob1").Activate

所以,修改如下:

Workbooks("kob1").Activate

它会很好用。