Results 1 to 4 of 4

Complie error: End If without If

Threaded View

Seler Naciowy Complie error: End If without... 11-28-2008, 01:26 PM
VBA Noob This should get you started ... 11-28-2008, 01:31 PM
solnajeff Compile error 11-28-2008, 01:35 PM
Seler Naciowy Thanks! 12-01-2008, 06:49 AM
  1. #1
    Registered User
    Join Date
    11-27-2008
    Location
    Everywhere
    Posts
    11

    Complie error: End If without If

    Hi,

    I'm writing a bit of a code that will re-format all sheets in spreadsheet except the three named. I keep on getting compile errors whatever I do. It's driven me mad.

    Could you please have a look at this and tell me what the heck is wrong?

    Sub formatsandsortall()
     Dim ws As Worksheet
     
     For Each ws In Worksheets
        If ActiveSheet.Name <> "name1" And ActiveSheet.Name <> "name2" And ActiveSheet.Name <> "name3" Then _
        Worksheets("ws").Select
        ActiveSheet.Cells.Select
        Selection.ClearFormats
        Selection.NumberFormat = "@"
        Columns("A:K").Select
        ActiveSheet.Sort.SortFields.clear
        ActiveSheet.Sort.SortFields.Add Key:=Range( _
            "A1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
            xlSortTextAsNumbers
        With ActiveSheet.Sort
            .SetRange Range("A:K")
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
        End If
       Next ws
    
     End Sub
    Thanks a million!
    Last edited by Seler Naciowy; 12-01-2008 at 07:54 AM.

Thread Information

Users Browsing this Thread

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

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