2011-05-18 79 views
0

我正在編寫一個VBA宏,但我得到了上述錯誤。我發現還有很多其他人出現這種常見錯誤,但是,對於每個人來說,解決方案似乎都不一樣。在我的宏代碼中,這個錯誤的原因是什麼?編譯錯誤:子或函數未定義

Sub Macro1() 
' 
' Macro1 Macro 
' Macro recorded 1/15/2010 by ' 

    Cells.Replace What:="NULL", Replacement:="", LookAt:=xlPart, SearchOrder _ 
     :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False 

    Cells.ReadingOrder = xlLTR 

    Cells.VerticalAlignment = xlTop 

    Rows("1:1").Font.Bold = True 


    With ActiveSheet.PageSetup 
     .PrintTitleRows = "$1:$1" 
     .LeftHeader = "Abbott Molecular Confidential" 
     '.CenterHeader = "Actions (Correction, Corrective and Preventive) Initiated" & Chr(10) & "From 9/1/2009 to 02/21/2011" 
     '.CenterHeader = "HCV Actions (Correction, Corrective and Preventive) Initiated" & Chr(10) & "From 9/1/2009 to 02/21/2011" 
     '.CenterHeader = "Investigations Created" & Chr(10) & "From 9/1/2009 to 02/21/2011" 
     '.CenterHeader = "HCV Investigations Created" & Chr(10) & "From 9/1/2009 to 02/21/2011" 
     '.CenterHeader = "ALK Complaints with Report Date" & Chr(10) & "From 1/1/2008 to 12/31/2010" 
     '.CenterHeader = "Process Exceptions" & Chr(10) & "From 05/16/2010 to 05/16/2011" 
     '.CenterHeader = "ALK Complaints By Lot Number" 
     '.CenterHeader = "All Process Nonconformances" & Chr(10) & "From 05/01/2009 to 04/30/2011" 
     '.CenterHeader = "2G28-90_Multilevel BOM, 8L070 and 1L31 Exceptions Initiated " & Chr(10) & "From 3/18/2011 to 4/4/2011" 
     '.CenterHeader = "Process Exceptions Initiated " & Chr(10) & "From 10/1/2010 to 04/26/2011" 
     '.CenterHeader = "Containments " & Chr(10) & "From 9/1/2009 to 02/21/2011" 
.CenterHeader = "Complaint Search for RT mS9 US" & Chr(10) & "From 02/09/2009 to 01/05/2011" 
     .RightHeader = "Printed on &D &T" 
     .RightFooter = "Page &P of &N" 
     .LeftFooter = "Data pulled on 05/18/2011" 
     .LeftMargin = Application.InchesToPoints(0.75) 
     .RightMargin = Application.InchesToPoints(0.75) 
     .TopMargin = Application.InchesToPoints(1) 
     .BottomMargin = Application.InchesToPoints(1) 
     .HeaderMargin = Application.InchesToPoints(0.5) 
     .FooterMargin = Application.InchesToPoints(0.5) 
     .Orientation = xlLandscape 
    End With 
End Sub 
+0

它說的哪個子或功能是未定義的?哪行代碼在調試器中突出顯示? – 2011-05-18 14:38:18

+0

運行時錯誤'448',找不到命名參數 – salvationishere 2011-05-18 14:44:54

+0

沒關係,我想通了。問題是我在模塊上而不是工作表上創建宏! – salvationishere 2011-05-18 14:53:07

回答

1

檢查VBA文檔版本的Excel的.Replace方法的參數。 *格式參數可能是稍後添加的。

0

另一種可能性: 當你寫一個新的宏一定要在開頭包括4個註釋行,如:

子Macro2() 「 」 Macro2()用於分析數據宏 '宏第2部分 ' 這擺脫了我的編譯錯誤

相關問題