+ Reply to Thread
Results 1 to 7 of 7

Repeatedly copy one row to next row and then hide first row

  1. #1
    Registered User
    Join Date
    01-10-2012
    Location
    malmö, sweden
    MS-Off Ver
    Excel 2003
    Posts
    3

    Repeatedly copy one row to next row and then hide first row

    Hi,

    This is my first posting here and I´m kind of overwhelmed and not quite sure I really understood how to search the archives. Please bear with me.

    ===

    In Excel 2007 I have a sheet with 25.000 rows where every even row (2, 4, 6, 8) has text in 11 columns but all uneven (1, 3, 5, 7) rows are empty.

    Now I need to

    1) copy the content in all even rows to the respectively next uneven row

    and then

    2) hide then even rows


    I have tried some VBA before but perhaps there is an easier way?
    And if not, would someone friendly perhaps give a hint about a suitable structure for the macro?

    Thanks a lot in advance

    Örjan
    Last edited by örjan; 01-11-2012 at 06:51 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Repeatedly copy one row to next row and then hide first row

    Hi örjan
    Welcome to the forum
    Why do you need to go that way??
    Why not just filter out the Blank cells with the filter option or shift all the data down one row then filter out the blanks?
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    01-10-2012
    Location
    malmö, sweden
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Repeatedly copy one row to next row and then hide first row

    Quote Originally Posted by pike View Post
    Hi örjan
    Welcome to the forum
    Why do you need to go that way??
    Why not just filter out the Blank cells with the filter option or shift all the data down one row then filter out the blanks?
    Hi pike,
    Thanks for your reply!

    Because I need every row to be in the file twice and the first one hidden.

    When I have that, I´ll import it to a translation tool where hidden rows are not shown/translated. (I do not know how the tool treats filtered rows.)
    When the translation is done and the file exported from the tool, I´ll hopefully will have a file with alternating rows of source and target language.

    Yesterday evening I played around until I had this macro:
    Please Login or Register  to view this content.
    Trouble is, it does not work when the rows are hidden and therefore I must do the hiding afterwards.
    I have been thinking about inserting a column with alternating '1' and '2' cells and sort on that. Then I could hide all '1' rows. But it depends on the table being absolutely regular. One missing or extra row and everything goes havoc.

    When I posted yesterday I thought maybe it would be possible to somehow first only show non-blanks rows, select, copy, then only show blank rows and insert there. Is it? Would it be more safe?

    Regardless of the method I´ll finally use, I have to somehow check that the resulting structure is correct.

    BR,
    Örjan
    Last edited by pike; 01-11-2012 at 04:48 AM. Reason: add code tags for newbie

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Repeatedly copy one row to next row and then hide first row

    ok try this on dummy data to make sure I have started on the correct row
    Please Login or Register  to view this content.

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Repeatedly copy one row to next row and then hide first row

    This may be slightly quicker

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-10-2012
    Location
    malmö, sweden
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Repeatedly copy one row to next row and then hide first row

    Hi pike,

    Wow!

    I just had to adopt the columns (B to K) and comment out the 'Else' (the even rows were the ones to be hidden) then it worked like a charm.

    Perfect. Thanks a million.



    Best regards

    Örjan

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Repeatedly copy one row to next row and then hide first row

    your welcome

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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