VBA for MS Excel - Copy, then Paste Loop Until End of Document

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MicheleDavidson
    New Member
    • Mar 2010
    • 7

    VBA for MS Excel - Copy, then Paste Loop Until End of Document

    VBA for MS Excel - Copy, then Paste Loop Until End of Document

    I need to copy text in row 1 and paste into row 2, and Loop paste into row 4, row 6, row 8, row 10, ect.
  • SammyB
    Recognized Expert Contributor
    • Mar 2007
    • 807

    #2
    Does this do what you want?
    Code:
    Option Explicit
    Sub Macro1()
        ' Determine last row
        Dim n As Integer, i As Integer
        n = Cells.SpecialCells(xlCellTypeLastCell).Row
        ' Copy the odd rows to the next row
        For i = 1 To n Step 2
            Rows(i).Copy Rows(i + 1)
        Next i
    End Sub

    Comment

    • MicheleDavidson
      New Member
      • Mar 2010
      • 7

      #3
      Originally posted by MicheleDavidson
      VBA for MS Excel - Copy, then Paste Loop Until End of Document

      I need to copy text in row 1 and paste into row 2, and Loop paste into row 4, row 6, row 8, row 10, ect.
      YES, thank you soooo much, you saved me a lot of time.

      Can I use the same Macro to copy formulas in row 3 columns 5 & 6 and paste into all of the odd number rows until the end of the document?

      Comment

      • SammyB
        Recognized Expert Contributor
        • Mar 2007
        • 807

        #4
        Somewhat the same:
        Code:
        Sub Macro2()
            ' Determine last row
            Dim n As Integer, i As Integer
            n = Cells.SpecialCells(xlCellTypeLastCell).Row
            ' Copy cells E3:F3 into the odd rows
            For i = 5 To n Step 2
                Range("E" & i & ":F" & i).FormulaR1C1 = Range("E3:F3").FormulaR1C1
            Next i
        End Sub

        Comment

        • MicheleDavidson
          New Member
          • Mar 2010
          • 7

          #5
          IT WORKED!! Thank you!

          Yes it worked great! Your Awesome! Thank you sooo much, I really appreciate it!!

          Comment

          Working...