+ Reply to Thread
Results 1 to 3 of 3

Macro terminates prematurely

Hybrid View

  1. #1
    Registered User
    Join Date
    06-05-2009
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    50

    Macro terminates prematurely

    Hi Forum Friends
    I have a macro to reset certain column that are offset by 13 to the right.
    If the test for the loop is ActiveCell = BLANK the macro works, but creates an
    un needed column at the end.
    If I test for a Blank cell before copying the formula the macro ends prematurely.
    I am stumped.
    Sub BClear()
        x = 0
        y = 0
        If Left(Range("L38"), 3) = "M-X" Then
            y = 8
        Else
            y = 13
        End If
        Range("F54:F100").Activate
        Selection.Copy
        Range("F54:F100").Offset(0, 10).Activate
        ActiveSheet.Paste
        Range("F40:F230").Activate
        Selection.Copy
        Do
            x = x + y
            Range("F40:F100").Offset(0, 10 + x).Activate
           ' ActiveCell.Offset(1, 0).Activate
            ActiveSheet.Paste
        Loop Until ActiveCell = BLANK          'works, but creates un-wanted column
        Loop Until ActiveCell.Offset(0, 10 + x + y) = BLANK   ' stops on column 107
        Stop
    End Sub
    Merry Christmas
    Al
    Attached Files Attached Files
    Last edited by aljanga; 12-26-2009 at 01:15 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-23-2009
    Location
    Hampshire, UK
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    328

    Re: Macro terminates pre-maturely

    I think it will stop correctly if you change your Loop line to
    Loop Until Range("F40").Offset(0, 10 + x + y) = BLANK

  3. #3
    Registered User
    Join Date
    06-05-2009
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    50

    Re: Macro terminates pre-maturely

    Thanks Huron
    Your suggested solution did the trick.
    Al

+ Reply to Thread

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