Results 1 to 3 of 3

Compile Error - how to fix?

Threaded View

pauldaddyadams Compile Error - how to fix? 11-17-2014, 06:57 AM
Andy Pope Re: Compile Error - how to... 11-17-2014, 07:00 AM
pauldaddyadams Re: Compile Error - how to... 11-17-2014, 07:31 AM
  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,702

    Compile Error - how to fix?

    Hi,

    I have copy and pasted the code supplied by Fotis on the post:

    HTML Code: 
    Into my main model and I get a the error "Compile Error - Variable not defined"

    How do I correct this?

    Sub Test()
    
    ActiveSheet.Cells.UnMerge
    
    For N = ActiveSheet.UsedRange.Rows.Count To 4 Step -1
        If InStr(Cells(N, 1), "APP024") > 0 Then
            Rows(N).Delete
        End If
        If WorksheetFunction.CountA(Rows(N)) = 0 Then
            Rows(N).Delete
        End If
        If InStr(Cells(N, 1), "APP024") > 0 Or InStr(Cells(N, 1), "Retail") > 0 Or InStr(Cells(N, 1), "Period") > 0 Or InStr(Cells(N, 1), "Code") > 0 Or InStr(Cells(N, 1), "Page") > 0 Then
            Rows(N).Delete
        End If
    
        If InStr(Cells(N, 1), "Sub-total") > 0 Then
            Rows(N).Font.Bold = True
            Rows(N).Font.ColorIndex = 3
            Rows(N).Font.Underline = xlUnderlineStyleDoubleAccounting
        End If
    Next N
    With Sheets("APP024")
    .Columns("B:B").ColumnWidth = 30
    .Columns("A:A").ColumnWidth = 10
    .Columns("C:H").ColumnWidth = 10
    
    .Rows("4:6").Insert Shift:=xlDown
    
    Range("A7") = "Code"
    Range("B7") = "Business"
    Range("C7") = "Ex VAT £"
    Range("D7") = "VAT £"
    Range("E7") = "INC VAT £"
    Range("F7") = "Ex VAT £"
    Range("G7") = "VAT £"
    Range("H7") = "INC VAT £"
    
    
    Range("C6:E6").Merge
    Range("F6:H6").Merge
    
    Range("C6:E6") = "Contributions From"
    Range("F6:H6") = "Contributions To"
    
    Range("A6:H7").Font.Bold = True
    End With
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  2. [SOLVED] Compile Error in Hidden Module and Compile Error: Can't find project or library
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2013, 07:03 PM
  3. compile error: compile error expected
    By odeno in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2008, 04:30 PM
  4. Replies: 3
    Last Post: 02-13-2006, 11:30 AM
  5. VBAProject name compile error, not defined at compile time
    By Matthew Dodds in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2005, 03:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1