Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop Until Specific Cell 1

Status
Not open for further replies.

HairyHippy

Programmer
Aug 5, 2004
53
GB
Hi All

Could you help me out again? I'm trying to loop a piece of code until cell A10 is reach, what is the loop until statement I need?

Code:
Sub AddNewClient()
    Application.Calculation = xlCalculationManual
    Dim x As Long
    Dim r As Range
    Do
        Rows(ActiveCell.Row).Select
        Rows("5:10").Copy
        Selection.Insert Shift:=xlDown
        Rows(ActiveCell.Row - 1).Select
        Selection.Rows.Group
    Loop Until (cell A10 reached)
    Application.Calculation = xlCalculationAutomatic
End Sub
 
Hi AdeyB,

normally this would be e.g.
Code:
Loop Until ActiveCell.Address="$A$10"

However, your are not selecting cells, but rows. So it would be
Code:
Loop Until ActiveCell.Row=10

Is that what you're looking for?
;-)
 
Hi,

Selecting Cells degrades performance, even with Application.ScreenUpdating = False. Using range refrerences makes for better code.

But you have a more fundamental logic problem, I think. You are copying and inserting 6 rows. This does not make sense.

Please explain what you are trying to accomplish, not in terms of code, but in terms of what's on the spreadsheet.

Skip,

[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue]
 
Thanks makeitso - that works! :)

Skip

I have a flat file (plain data) that I need to insert certain lines in between with formulas and formatting. My code starts at the last cell in column A and copies and inserts the formating and formulas between each row. If there is a better way of doing this, I'd like to know. Sorry can't be more explicit on the data but it is sensitive.

Thanks guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top