+ Reply to Thread
Results 1 to 9 of 9

Make duplicates of rows, 4 colums.

Hybrid View

  1. #1
    Registered User
    Join Date
    10-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2016
    Posts
    78

    Make duplicates of rows, 4 colums.

    Found several posts about how to make duplicates but all of them only made duplicates of 1 colum.

    I got 4 colums and 80 rows and I wanna just make duplicates of all of them.

    Any VBA code for that or another simple trick?

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,754

    Re: Make duplicates of rows, 4 colums.

    Where would you like the duplicates to appear. Suppose your first row of data is in A2:D2, where would the duplication appear?
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    10-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2016
    Posts
    78

    Re: Make duplicates of rows, 4 colums.

    Let's say it look like this

    Colum A - First Name
    Bill
    Steve
    Hugh

    Colum B - Surname
    Gates
    Jobs
    Heffner

    Colum C - ID-Number
    1337
    1285
    1234

    Colum D - Position
    CEO
    Dead
    Legend


    And I want it to duplicate it all just the row below/above, doesn't mather.

    So it would look like this

    Bill Gates 1337 CEO
    Bill Gates 1337 CEO
    Steve Jobs 1285 Dead
    Steve Jobs 1285 Dead
    Hugh Heffner 1234 Legend
    Hugh Heffner 1234 Legend
    Last edited by Challebjoern; 12-03-2015 at 06:10 AM.

  4. #4
    Registered User
    Join Date
    10-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2016
    Posts
    78

    Re: Make duplicates of rows, 4 colums.

    Option Explicit
    
    Sub TimesFive()
    Dim LR As Long:     LR = Range("A" & Rows.Count).End(xlUp).Row
    Dim BR As Long:     BR = LR * 2
    
    Rows("1:" & LR).Copy Rows(LR + 1 & ":" & BR)
    Range("A1").CurrentRegion.Sort Key1:=[A1], Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
    
    End Sub

    Found this code that worked, but it duplicates everything in the sheet which is kinda annoying.
    Last edited by Challebjoern; 12-03-2015 at 10:51 AM.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,754

    Re: Make duplicates of rows, 4 colums.

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (Because you are new to the forum, I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)

  6. #6
    Registered User
    Join Date
    10-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2016
    Posts
    78

    Re: Make duplicates of rows, 4 colums.

    Ah Sorry, I've read it now and will do it better in the future! Did you have any solution for my issue with code?


    Quote Originally Posted by alansidman View Post
    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (Because you are new to the forum, I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Make duplicates of rows, 4 colums.

    Does this help?

    Sub Challebjoern()
    Dim i As Long, x As Long
    For i = Range("A" & Rows.Count).End(3).row To 2 Step -1
        x = 2
        Do Until x = 1
        Range(Cells(i, "A"), Cells(i, "D")).Copy
        Cells(i, "A").Insert xlDown
        x = x - 1
        Loop
    Next i
    End Sub

  8. #8
    Registered User
    Join Date
    10-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2016
    Posts
    78

    Re: Make duplicates of rows, 4 colums.

    Hey John. That does the trick! Thanks alot.

    Quote Originally Posted by JOHN H. DAVIS View Post
    Does this help?

    Sub Challebjoern()
    Dim i As Long, x As Long
    For i = Range("A" & Rows.Count).End(3).row To 2 Step -1
        x = 2
        Do Until x = 1
        Range(Cells(i, "A"), Cells(i, "D")).Copy
        Cells(i, "A").Insert xlDown
        x = x - 1
        Loop
    Next i
    End Sub

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Make duplicates of rows, 4 colums.

    You're welcome. Glad to help out and thanks for the feedback. Please mark this thread as SOLVED: Click Thread Tools above your first post, select "Mark your thread as Solved"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 06-30-2015, 06:42 PM
  2. [SOLVED] Identify duplicates across multiple colums and rows
    By JMichaelson1967 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-26-2013, 02:01 PM
  3. Multiple rows are duplicates EXCEPT only ONE cell. Make that ONE cell a list
    By ikesmith08 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2013, 12:35 PM
  4. find duplicates sort then next colums data combined
    By farrukh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-30-2012, 06:04 PM
  5. [SOLVED] On selection, find dups in two colums across workbook, copy duplicates to existing sheet.
    By Joshuarat in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-21-2012, 07:54 PM
  6. Identify Duplicates in columns and copy corresponding colums in next column
    By sreesatya in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-04-2012, 01:02 PM
  7. Replies: 0
    Last Post: 07-11-2011, 04:49 AM

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