salvationishere
salvationishere

Reputation: 3511

Compile error: Sub or function not defined

I'm coding a VBA Macro, but I get the above error. I see that there are many others with this common error, however, the solution seems to be different for each person. What is the cause of this error in my Macro code below?

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

Upvotes: 0

Views: 2073

Answers (2)

dpoole
dpoole

Reputation: 1

Another possibility: When you write a new macro be sure to include 4 comment lines at the beginning, such as:

Sub Macro2() ' ' Macro2() Macro ' Macro for parsing data part 2 ' This got rid of the compile error for me

Upvotes: 0

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38775

Check the VBA documentation for your version of Excel for the parameters of the .Replace method. The *Format arguments may be a later addition.

Upvotes: 1

Related Questions