• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy and paste when double clicked

kalua1231

Member
Copy specific row Column (C) and show in ROW 2, COLUMN (C). very simple will have attachment with pics and codes. Thank You.

Code Beneath here
-----------------------------------------------------------------------------------------------

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

Dim dccolumn As Integer
Dim dcvalue As String

dccolumn = ActiveCell.Column
dcvalue = ActiveCell.Value

If Application.Intersect(ActiveCell, [headers]) Is Nothing Then

If ActiveCell.Value <> "" Then

ActiveSheet.ShowAllData

ActiveSheet.ListObjects("Table134").Range.AutoFilter Field:=5, Criteria1:=Selection.Text

End If

End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False

Dim rownumber As Integer

rownumber = ActiveCell.Row

If Application.Intersect(ActiveCell, [headers]) Is Nothing Then
If ActiveCell.Value <> "" Then
Range("a1:i5000").Interior.ColorIndex = xlNone
Range("a" & rownumber & ":i" & rownumber).Interior.Color = RGB(255, 255, 9)
End If
End If
 

Attachments

  • Input Word 1.jpg
    Input Word 1.jpg
    166.8 KB · Views: 16
  • Input Word 2.jpg
    Input Word 2.jpg
    227.3 KB · Views: 14
  • Fix 8 20.xlsm
    203.3 KB · Views: 2
Not sure what the selection event macro is doing, and it'll probably interfere w/ you trying to double click. To do just what you asked, change double-click event to

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim myRange As Range
  
    'What range to monitor?
    Set myRange = Me.ListObjects(1).ListColumns("Name").DataBodyRange
  
    'Did user click here?
    If Not (Intersect(myRange, Target) Is Nothing) Then
        Range("C2").Value = Target.Value
        Cancel = True
    End If
  
End Sub

Also, since you have a merged cell, you can't actually see cell C2. Perhaps you wanted the value in A1, centered?
 
Would need to know what they are trying to do. Neither block of original code had any comments, so I don't know what to do.

Whenever we deal with code, it's much easier if we start with knowing overall goal and go from there, rather than try to just splice bits of code together. Faster to solve, and lets us (the solvers) potentially come up with better ways of doing things.
 
Hey luke thanks a mil bro with your suggestion i had only use part of that and place it on the other code. It works great.

If Application.Intersect(ActiveCell, [headers]) Is Nothing Then

Range("C2").Value = Target.Value
Cancel = True


If ActiveCell.Value <> "" Then

ActiveSheet.ShowAllData

ActiveSheet.ListObjects("Table134").Range.AutoFilter Field:=5, Criteria1:=Selection.Text

End If

End If

End Sub
 
Back
Top