0

I am trying to repeat this process x amount of times, but I keep getting the message "Compile Error: Loop without Do"

Here is my code

Do Until x > 10
    x = x + 1
    For Each Row In propertytable
    Range("A2,B2,C2,D2,E2").Select
    Range("E2").Activate
    Selection.Copy
    Sheets("Copy to' sheet").Select
    Range("A1").Select
    ActiveSheet.Paste
    Rows("1:1").Select
    Application.CutCopyMode = False
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Sheets("Property table").Select
    Rows("2:2").Select
    Selection.Delete Shift:=xlUp
    Sheets("Copy to' sheet").Select
Loop   

Thanks in advance for any help you may be able to provide.

2
  • 6
    You're missing a Next Row before Loop Commented Jan 8, 2014 at 5:31
  • I suggest you install the MZ-Tools utility. It will automatically indent your code for you. This makes it easier to spot mistakes like this. Commented Jan 8, 2014 at 8:18

1 Answer 1

2

Indenting your code would've made the omission of Next Row more apparent.

Do Until x > 10
    x = x + 1
    For Each Row In propertytable
        Range("A2,B2,C2,D2,E2").Select
        Range("E2").Activate
        Selection.Copy
        Sheets("Copy to' sheet").Select
        Range("A1").Select
        ActiveSheet.Paste
        Rows("1:1").Select
        Application.CutCopyMode = False
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        Sheets("Property table").Select
        Rows("2:2").Select
        Selection.Delete Shift:=xlUp
        Sheets("Copy to' sheet").Select
    'with indent it's obvious there's something missing
    Next Row
Loop

I think you may have some other compile errors in there that you will find after adding the Next Row command.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help. I am having a bit of trouble getting it to compile. I'll keep working on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.