+ Reply to Thread
Results 1 to 4 of 4

Double click to copy and paste value to first available row.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Double click to copy and paste value to first available row.

    I need to be able to copy data from a range "G18:T43" and then by double clicking on a row, copy the data only to a target range, rows "G9:G15" on a first available blank row basis. I hope this is clear enough, if not let me know and I will try to be more specific.


    Thanks

    Jim O
    Last edited by JO505; 01-16-2013 at 05:37 PM.

  2. #2
    Forum Contributor
    Join Date
    10-19-2012
    Location
    Omaha, Nebraska USA
    MS-Off Ver
    Excel 2010
    Posts
    249

    Re: Double click to copy and paste value to first available row.

    Hi Jim,

    I posted some code below that copies the cells from column G to T whenever a cells in the range from G18:T43 is double-clicked per what I understood from your description. The worksheet is posted also so you can see how it works and if it is what you were looking for.

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
    Dim i As Long
    Dim sRow As Long
    
    If Not Intersect(Target, Range("G18:T43")) Is Nothing Then
      sAddress = Target.Address
      i = InStr(2, Target.Address, "$")
      sRow = Right(Target.Address, Len(Target.Address) - i)
    
      ' Move Row
      For i = 9 To 15
        If IsEmpty(Range("G" & i)) Then
          Range("G" & sRow & ":T" & sRow).Copy
          Range("G" & i).Select
          ActiveSheet.Paste
          Target.Select
          GoTo 10
        End If
      Next i
      MsgBox "There are no empty rows from ""G9:G15"", nothing has been copied."
    End If
    
    10 End Sub
    Thanks,

    Daniel
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Double click to copy and paste value to first available row.

    Daniel,
    Thanks for the response.

    That is very close to what I am looking for but I am having a problem with the code. I pasted the code in my sheet and it almost works. By that I mean it will copy the format of the row but not the value. The section being copied is formated in a color and the data is displayed with formulas. The code copies the format but not the data. I dont care if the format is copied or not but it is the data I am trying to copy.

    Also I will need to apply this to some other sheets in the workbook and I assume I can do so by adjusting the cell ranges as necessary.

    Jim O

  4. #4
    Forum Contributor
    Join Date
    05-10-2011
    Location
    Central Ohio
    MS-Off Ver
    Excel 2000, and 2010
    Posts
    654

    Re: Double click to copy and paste value to first available row.

    Daniel,

    Iv'e got it working now. Thank you for pointing me in the right direction.

    Jim O

+ 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