'sub或function not defined'错误

时间:2014-02-04 09:11:06

标签: excel-vba vba excel

我在下面的程序中遇到Sub or Function not defined错误的问题。有谁可以帮我解决这个问题?

主要宏:

Private Sub CommandButton1_Click()
    EraseWorkSheetKeepRow1 ("FilteredItems")
     Sheets("SalesData").Select
    Dim i As Integer
    Dim k As Integer
    k = Application.WorksheetFunction.CountA(Range("A:A"))
    For i = 2 To k
        Sheets("SalesData").Select
        If Val(Cells(i, 3)) > Val(TextBox1.Text) Then
          Call Copy1row("SalesData", i, "FilteredItems")
        End If

    Next
End Sub

Sub Routine1(EraseWorkSheetKeepRow1):

Sub EraseWorkSheetKeepRow1(sheetname As String)
'
' EraseWorkSheetKeepRow1 Macro
' Erase all rows except row 1 for worksheet
    ActiveWorkbook.Sheets(CustomerInfo).Select
    Dim k As Integer
    k = Application.WorksheetFunction.CountA(Range("A:A")) + 1
    Range("A2:C" & k).Select
    Selection.ClearContents
End Sub

Sub Routine2(Copy1row):

Sub Copy1row(FromSheet As String, rowno As Integer, ToSheet As String)
'
' Copy1row Macro
    Sheets(CustomerInfo).Select
    Rows(rowno & ":" & rowno).Select
    Selection.Copy
    Sheets(ToSheet).Select
    Dim k As Integer
    k = Application.WorksheetFunction.CountA(Range("A:A")) + 1
    Rows(k & ":" & k).Select
    Selection.PasteSpecial _
        Paste:=xlPasteAll, _
        Operation:=xlNone, _
        SkipBlanks:=False, _
        Transpose:=False
End Sub

1 个答案:

答案 0 :(得分:0)

此错误通常与代码本身无关。请检查子名称是否与模块名称不同,并且您在另一个子组件中没有使用相同的名称,因为这可能导致定义错误。