+ Reply to Thread
Results 1 to 2 of 2

Getting compile error when using End(xlToLeft)

Hybrid View

  1. #1
    Registered User
    Join Date
    05-13-2013
    Location
    London
    MS-Off Ver
    Excel 2010 Mac
    Posts
    19

    Getting compile error when using End(xlToLeft)

    Hi there,

    I'm having a problem with coding that doesn't usually cause me any problems.

    I've created a loop that will go through columns of data and copy and paste them onto another sheet. It looks like this:

    FinalC = Cells(1, Columns.Count).End(xlToLeft).Column
    For s = 7 To FinalC
        Cells(5, s).Select
        If Cells(5, s) = "" Then
            Exit For
        Else
            Range(Selection.End(xlDown), Selection).Copy
            Sheets("csv").Activate
                FinalR4 = Cells(Rows.Count, 1).End(xlUp).Row
                Range("f" & FinalR4).Select
                ActiveCell.Offset(1, 0).Select
                ActiveSheet.Paste
                    Sheets("Sheet1").Activate
        End If
        Sheets("Sheet1").Activate
    Next s
    The error I'm getting is this:
    Compile error:
    Only comments may appear after End Sub, End Function or End Property.
    Then it highlights the End(xlToLeft) part of my code. Can anyone see anything wrong with this?

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    05-13-2013
    Location
    London
    MS-Off Ver
    Excel 2010 Mac
    Posts
    19

    Re: Getting compile error when using End(xlToLeft)

    Just noticed that an 'End Sub' we typed somewhere earlier in the code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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