+ Reply to Thread
Results 1 to 2 of 2

Loop Function unable to loop

  1. #1
    Junior728
    Guest

    Loop Function unable to loop

    Hi,

    I am doing a macro that uses Do Until...Loop to process on certain column
    data(Col G) and go thru row by row on my wksheet and print that
    string(Print#2) onto a script txt file.

    The problem is i am always stuck at row 1 and does not automatically go to
    the next row of data. CAn anyone advise why is this so and how to?

    My Example:

    Sub test( )
    Do Until ActiveCell.Row > LastRow

    ActiveCell.FormulaR1C1 = Range("G2")
    Total$ = ActiveCell.FormulaR1C1

    If ActiveCell.FormulaR1C1 = "" Then GoTo Skiptohere

    Print #2, "testing"
    Print #2, "testing"
    Print #2, "testing"

    Skiptohere:
    Print #2, " #End script file"
    Close #2

    ActiveCell.Offset(1, 0).Range("A7").Select
    Loop
    End Sub

  2. #2
    Bob Phillips
    Guest

    Re: Loop Function unable to loop

    Not sure what you are trying to do but I have revamped so

    Sub test()
    LastRow = 7
    For i = ActiveCell.Row To LastRow

    Cells(i, ActiveCell.Column).FormulaR1C1 = Range("G2")
    Total$ = Cells(i, ActiveCell.Column).FormulaR1C1

    If Cells(i, ActiveCell.Column).Value = "" Then GoTo Skiptohere

    Print #2, "testing"
    Print #2, "testing"
    Print #2, "testing"

    Skiptohere:
    Print #2, " #End script file"
    Close #2

    Next i
    End Sub


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Junior728" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I am doing a macro that uses Do Until...Loop to process on certain column
    > data(Col G) and go thru row by row on my wksheet and print that
    > string(Print#2) onto a script txt file.
    >
    > The problem is i am always stuck at row 1 and does not automatically go to
    > the next row of data. CAn anyone advise why is this so and how to?
    >
    > My Example:
    >
    > Sub test( )
    > Do Until ActiveCell.Row > LastRow
    >
    > ActiveCell.FormulaR1C1 = Range("G2")
    > Total$ = ActiveCell.FormulaR1C1
    >
    > If ActiveCell.FormulaR1C1 = "" Then GoTo Skiptohere
    >
    > Print #2, "testing"
    > Print #2, "testing"
    > Print #2, "testing"
    >
    > Skiptohere:
    > Print #2, " #End script file"
    > Close #2
    >
    > ActiveCell.Offset(1, 0).Range("A7").Select
    > Loop
    > End Sub




+ 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