+ Reply to Thread
Results 1 to 3 of 3

Add specific cells in row next to active cell

  1. #1
    Registered User
    Join Date
    08-18-2009
    Location
    chiago,usa
    MS-Off Ver
    Excel 2007
    Posts
    4

    Add specific cells in row next to active cell

    Hi,

    I need you help to solve a poblem with my macro.

    I would like to copy current row next to my active cell but only specific cells using Macro. I have a existing Macro as below which copies the current row and copies into next row.

    Sub Macro1()
    'make new row
    ActiveCell.EntireRow.Insert Shift:=xlDown
    'copy the row above
    ActiveCell.Offset(1, 0).EntireRow.Copy Cells(ActiveCell.Row, 1)
    End Sub

    But I dont want to copy entire row..Only specific cells.

    I have attached a example. In the attached example, I have data in 10 rows and 10 columns. When my cursor is on row 4(activecell) and I run the Macro it creates a new row next to row 4 and copies data from row 4. But I dont want to copy entire row. I want to copy only values in column A, Column D-G from the active cell row to next row. I would like to do this whenever the macro runs.

    I appreciate your help.

    Thanks in advance.

    Senthil
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Add specific cells in row next to active cell

    Hi,

    You could try ...

    Sub Macro1()
    Dim i As Long
    i = ActiveCell.Row
    'make new row
    ActiveCell.EntireRow.Insert Shift:=xlDown
    'copy info form above
    Cells(i + 1, 1).Value = Cells(i, 1).Value
    Cells(i + 1, 4).Value = Cells(i, 4).Value
    Cells(i + 1, 7).Value = Cells(i, 7).Value
    End Sub
    HTH

  3. #3
    Registered User
    Join Date
    08-18-2009
    Location
    chiago,usa
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Add specific cells in row next to active cell

    Thank you HTH.

    I tried your macro. It works as I expected for the next row, but it deletes the current row. I would like to keep the data in the current row..

    Can you please help.

    Thanks,
    Senthil

+ 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