Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Atlanta, GA
    Posts
    220
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro to copy contents of a row (Office 2000)

    I want to create a macro that inserts a row and copies the contents of the row directly under it. The macro could be used from anywhere on the worksheet so I'll have a different row that will be selected each time.

    Let's say I have a Name in b1 and an address in c1. I would want to run the macro, insert a row and copy the contents of (now b2 and c2) to the new b1 and c1.

    Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to copy contents of a row (Office 2000)

    This one should do it:

    Sub InsertCopy()
    With Selection.EntireRow
    .Copy
    .Insert
    End With
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Atlanta, GA
    Posts
    220
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to copy contents of a row (Office 2000)

    That worked but after I tried it I realized that I needed to copy only selected columns in a row. How can I do this without knowing where the cursor might be in the row?

    Thanks.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to copy contents of a row (Office 2000)

    If you only need to insert/copy the selection, use

    Sub InsertCopy()
    With Selection
    .Copy
    .Insert Shift:=xlShiftDown
    End With
    End Sub

    Since you're not inserting an entire row, you must now specify that the cells should be shifted down, not to the right.

  5. #5
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Atlanta, GA
    Posts
    220
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to copy contents of a row (Office 2000)

    Thanks.

    Looks like this is the one I need.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •