+ Reply to Thread
Results 1 to 3 of 3

Copy cells from active row to inserted blank row below, part way there..

Hybrid View

  1. #1
    Registered User
    Join Date
    04-22-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    59

    Copy cells from active row to inserted blank row below, part way there..

    I culled this code from another source and it does part of what I need but I was hoping it would be possible to develop it slightly to automate a task further

     Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
       Cancel = True
        Target.Offset(1).EntireRow.Insert
        Target.EntireRow.Copy Target.Offset(1).EntireRow
        On Error Resume Next
        Target.Offset(1).EntireRow.SpecialCells(xlConstants).ClearContents
        On Error GoTo 0
    End Sub

    The codes so far inserts a blank row below the active row that is double clicked. What I was aiming for was to also copy the contents of the double clicked row ( just columns C to F) into the new row that is created. The icing would be to add the text "Split" into column J (again of the newly created row)

    Any help with any part of this code would be appreciated.

    Many thanks

    P.S is it just my imagination or have the code tags buttons gone from the page, I had to manually type them in this time round?

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Copy cells from active row to inserted blank row below, part way there..

     Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
       Cancel = True
       Target.EntireRow.Copy
       Target.Offset(1).EntireRow.Insert
       Range("J" & Target.Offset(1).Row) = "Split"
       Application.CutCopyMode = False
    '   Target.EntireRow.SpecialCells(xlConstants).ClearContents
    End Sub
    If solved remember to mark Thread as solved

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Copy cells from active row to inserted blank row below, part way there..

    Hi, coasterman,

    as you asked for only inserting a part of the columns instead of an entire row:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
       Cancel = True
       Target.Offset(1).EntireRow.Insert
       Range("C" & Target.Row & ":F" & Target.Row).Copy Destination:=Range("C" & Target.Row + 1)
       Range("J" & Target.Row + 1) = "Split"
    End Sub
    No, everything on the forum software should have returned to normal usage - highlight your code and hit the #-sign if you are in advanced mode for answering.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. copy destination below the last active row or the first blank row.
    By Bpd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2013, 10:42 AM
  2. 2 part piece here. One part counter of up and down, fill in of blank cells.
    By greenfox74 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-04-2012, 10:09 PM
  3. How to copy VBA codes to cells that are inserted to a spreadsheet
    By Triscia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-03-2012, 01:56 PM
  4. Replies: 15
    Last Post: 11-01-2012, 12:58 PM
  5. Excel inserted 0's in cells linked to blank cells
    By lburg801 in forum Excel General
    Replies: 5
    Last Post: 10-28-2005, 06:32 PM

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