Loop to copy multiple cells

%3CLINGO-SUB%20id%3D%22lingo-sub-2221361%22%20slang%3D%22en-US%22%3ELoop%20to%20copy%20multiple%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2221361%22%20slang%3D%22en-US%22%3E%3CP%3EPlease%20help%2C%20I'm%20going%20in%20circles!%3C%2FP%3E%3CP%3EI%20need%20to%20create%20a%20macro%20to%20populate%20column%20E%20with%20the%20values%20in%20column%20K%2C%20but%20it%20will%20copy%20J2%23%20of%20times.%3C%2FP%3E%3CP%3EThe%20data%20in%20this%20file%20is%2010%20unique%20rows%20that%20repeat.%20So%20E2%3DK2%20and%20copy%20it%20J2%20number%20of%20times%20(10).%20Then%20E12%3DK3%2C%20and%20copy%20that%20J2%20number%20of%20times%20and%20continue%20until%20there%20are%20no%20more%20values%20listed%20in%20column%20K.%20I%20hope%20this%20makes%20sense.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Capture.JPG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F265405i2393964BD0D1D336%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Capture.JPG%22%20alt%3D%22Capture.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2221361%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

Please help, I'm going in circles!

I need to create a macro to populate column E with the values in column K, but it will copy J2# of times.

The data in this file is 10 unique rows that repeat. So E2=K2 and copy it J2 number of times (10). Then E12=K3, and copy that J2 number of times and continue until there are no more values listed in column K. I hope this makes sense.Capture.JPG

1 Reply

@AprilMo 

Here you go:

Sub CopyData()
    Dim n As Long
    Dim r As Long
    Dim m As Long
    Dim s As Long
    Application.ScreenUpdating = False
    n = Range("J2").Value
    s = 2
    m = Range("K1").End(xlDown).Row
    For r = 2 To m
        Range("E" & s).Resize(n).Value = Range("K" & r).Value
        s = s + n
    Next r
    Application.ScreenUpdating = True
End Sub