+ Reply to Thread
Results 1 to 8 of 8

Copy/Paste Cells To/From Every Other Row

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    Indiana
    MS-Off Ver
    Excel 2010
    Posts
    4

    Copy/Paste Cells To/From Every Other Row

    I have a worksheet that is 2201 rows long (with header row), and every other row is a duplicate of the one above it. For every duplicate set, I need to copy column C in the first row and paste it into column B in the second row. For example (first column is B and second column is C):

    01/01/2012 12/31/2012
    01/01/2012 12/31/2012
    01/01/2013 12/31/2013
    01/01/2013 12/31/2013

    The above needs to look like this when I'm done:

    01/01/2012 12/31/2012
    12/31/2012 12/31/2012
    01/01/2013 12/31/2013
    12/31/2013 12/31/2013

    Does anyone know of an easy way to do this? I have tried to do this by hand, but it's going to take hours. I've attached a workbook (Copy&PasteExample.xlsx) with a sample. (Note: Column C in the workbook will be deleted after all of the dates are moved, so formulas cannot rely on that column's data remaining.)

    I am working in Excel 2010 and I am a beginner at working with macros.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Copy/Paste Cells To/From Every Other Row

    Does column B in the 2nd row already have data in it which needs to be replaced with data from column C?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    08-01-2012
    Location
    Indiana
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Copy/Paste Cells To/From Every Other Row

    Yep, it does.

    Also, I just realized something silly. It doesn't matter if the data in Row C is copied from the first or second row of the duplicate set since they're the same. So, if it's easier to copy/paste from the same row instead of two different rows, that is fine.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Copy/Paste Cells To/From Every Other Row

    So you mean that data in row 3 (considering that rows 2 & 3 are containing duplicates) column C can be copied over to column B?

  5. #5
    Registered User
    Join Date
    08-01-2012
    Location
    Indiana
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Copy/Paste Cells To/From Every Other Row

    Sorry, I'm being confusing. For example:

    01/01/2012 12/31/2012
    01/01/2012 12/31/2012

    Pretend the two columns above are Rows 1 and 2, Columns B and C. I mean that since they're duplicates, the date can be copied from either C1 or C2 to B2.

    After playing with my spreadsheet, it actually looks like this now:

    01/01/2012
    01/01/2012 12/31/2012

    So, I really just need something that can easily copy C2 to B2, and perform that function for every other row. Would it help if I posted a new worksheet? (Sorry to be so confusing!)

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Copy/Paste Cells To/From Every Other Row

    I am fine

    Try this code
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button

  7. #7
    Registered User
    Join Date
    08-01-2012
    Location
    Indiana
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Copy/Paste Cells To/From Every Other Row

    Actually, I may have figured out a weird workaround.

    In a blank column off to the right, I entered the following:

    =B1
    =C2

    Then, I highlighted those two cells and used the fill handle to copy that formula set all the way down the spreadsheet. That populated the dates I needed. Then, I just copied that column and pasted it over column B. I'm sure there's a fancier way to do it, but this works for me. Sorry for all the hubbub!

    Thanks for the help, arlu1201!
    Last edited by kethryvalis; 08-01-2012 at 03:13 PM.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Copy/Paste Cells To/From Every Other Row

    Hey np.

    The code was easy to do as well...just a couple of mins

    ---------- Post added at 12:37 AM ---------- Previous post was at 12:36 AM ----------

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

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    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