0

I am looking for a way to duplicate and rearrange some data that I have using a macro or a function that exists. Any help would be greatly appreciated.

Thank you in advanced!

J

The data is unique ID numbers listed in Column A like below.

Unique ID Numbers - Starting Point

I am trying to have each number duplicated 4 times in a row like the below image...

enter image description here

2 Answers 2

3

With your data in column A in B1 enter:

=INDIRECT("A" & ROUNDUP(ROW()/4,0))

and copy down

Then copy column B and Paste/Special/Values back onto column A

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

1 Comment

=INDEX(A:A,ROUNDUP(ROW()/4,0)) avoids the volatility ;)
1
Sub myMacro()

    ' where data is
    Dim rowData As Integer
        rowData = 2

    ' where data is duplicated 4 times
    Dim rowNew As Integer
        rowNew = 1

    ' loop through all entries of column A
    Do While Range("A" & rowData).Value <> ""

        Do While rowNew Mod 4 <> 0

            ' copy
            Range("B" & rowNew).Value = Range("A" & rowData).Value
            rowNew = rowNew + 1

        Loop

        ' last copy
        Range("B" & rowNew).Value = Range("A" & rowData).Value
        rowNew = rowNew + 1

        ' next row
        rowData = rowData + 1

    Loop

End Sub

Comments

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.