copy paste double click

es0019

New Member
Joined
Jul 24, 2018
Messages
12
Hello
IF anyone can help me please
My question is how can make it work when double clicking on cell copy the contents of this cell and from another cell and then paste the contents from both at another cells.For examble double click on cell D4 copy the contents of D4 and contents of K4 from the same row and paste them with one click to any other active cell let say clicking on cell v60 to paste D4 and on W60 to paste K4

Thanks
 
Thanks for your try.
Sounds like it didn't do what you wanted & I was expecting that. If so, I'm sorry I couldn't understand what you wanted. If you are able to clarify it better I would be happy to try again.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You are right.Just i want to use your code with double click working perfect for copy, BUT I am asking if you can to change the paste destination to these 13 pairs and only the contains NOT anywhere to the sheet
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
If Target.Column = 4 Then Union(Target, Target.Offset(, 7)).Copy
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.CutCopyMode = xlCopy Then
ActiveSheet.Paste
Application.CutCopyMode = False
End If​

End Sub

Thanks again
 
Last edited:
Upvote 0
You are right.Just i want to use your code with double click working perfect for copy, BUT I am asking if you can to change the paste destination to these 13 pairs and only the contains NOT anywhere to the sheet
OK, so the question I asked before is still the same.

.. a specific example.

Suppose I double-click on D6

1. Can you confirm that we still should copy D6 and K6

2. Now, we have to paste (values only) somewhere. You have listed 13 pairs of cells.
- Should the two values get pasted 13 times into all those cells?
- If not, do the 2 values get pasted into one of those 13 pairs of cells? If so, how do we decide which pair of those cells we paste the values into?

Are you able to answer the above question, or is the answer shown below?

Do you mean this ..
After a cell in column B has been double clicked and the two cells copied, I only want it pasted when the next cell is selected if the user selects one of the red cells below. For example
if the user selects V63 the values would get put into V63 and W63
if the user selects X66 the values would get put into X66 and W66
if the user selects F29 the values would not get put anywhere

              X60 W60
V61 W61 X61 W61
V62 W62 X62 W62
V63 W63 X63 W63
V64 W64 X64 W64
V65 W65 X65 W65
V66 W66 X66 W66
 
Last edited:
Upvote 0
Thanks for your patince. Yes I would like to be exactly as in your example
After a cell in column B has been double clicked and the two cells copied, I only want it pasted when the next cell is selected if the user selects one of the red cells below. For example
if the user selects V63 the values would get put into V63 and W63
if the user selects X66 the values would get put into X66 and W66
if the user selects F29 the values would not get put anywhere

X60
W60
V61
W61
X61
W61
V62
W62
X62
W62
V63
W63
X63
W63
V64
W64
X64
W64
V65
W65
X65
W65
V66
W66
X66
W66
<strike></strike>
 
Last edited:
Upvote 0
Try this
Code:
Private CopyCell As Range

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  If Target.Column = 4 Then
    Cancel = True
    Set CopyCell = Target
  End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If Not CopyCell Is Nothing Then
    If Not Intersect(ActiveCell, Range("V61:V66, X60:X66")) Is Nothing Then
      ActiveCell.Value = CopyCell.Value
      Range("W" & ActiveCell.Row).Value = CopyCell.Offset(, 7).Value
      Set CopyCell = Nothing
    End If
  End If
End Sub
 
Last edited:
Upvote 0
Thanks it works perfect at new empty workbook ,but in my workbook I am getting error 424 object required
This is the code at entire worksheet with your code. Can you please check what is going wrong?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim srow As Double
If Left(Target.Address, 2) = "$Q" Then
srow = Target.Row
[V40].Value = Cells(srow, 17)
[W40].Value = Cells(srow, 2)
[Y40].Value = Cells(srow, 3)
[W41].Value = Cells(srow, 7)
[Y41].Value = Cells(srow, 13)
[V43].Value = Cells(srow, 8)
[X43].Value = Cells(srow, 6)
[V45].Value = Cells(srow, 4)
[X45].Value = Cells(srow, 5)
[X47].Value = Cells(srow, 16)
[X49].Value = Cells(srow, 9)
[W51].Value = Cells(srow, 20)
[X51].Value = Cells(srow, 11)
[V55].Value = Cells(srow, 17)
[W55].Value = Cells(srow, 2)
[Y55].Value = Cells(srow, 3)
[W56].Value = Cells(srow, 7)
[Y56].Value = Cells(srow, 13)
[X58].Value = Cells(srow, 16)
[W67].Value = Cells(srow, 20)
[V60].Value = Cells(srow, 4)
[W60].Value = Cells(srow, 11)
If Left(Target.Value, 3) = "DOR" Then
Cells(Target.Row, 21).FormulaR1C1 = "=ifNA(MATCH(RC[-4],'BAYS '!R6,0),0)"
srow = Cells(Target.Row, 21).Value
Cells(Target.Row, 21).Value = ""
Sheets("BAYS ").Cells(9, srow).Value = Cells(Target.Row, 7)
Sheets("BAYS ").Cells(7, srow).Value = Cells(Target.Row, 19)
Sheets("BAYS ").Cells(8, srow).Value = Cells(Target.Row, 16)
ElseIf Left(Target.Value, 3) = "PAD" Then
Cells(Target.Row, 21).FormulaR1C1 = "=ifNA(MATCH(RC[-4],'BAYS '!R15,0),0)"
srow = Cells(Target.Row, 21).Value
Sheets("BAYS ").Cells(16, srow).Value = Cells(Target.Row, 20)
Sheets("BAYS ").Cells(17, srow).Value = Cells(Target.Row, 19)
End If
End If
On Error Resume Next
If Target.Column = 1 Then
If Target.Validation.Type = 3 Then
Application.EnableEvents = False
Target.Offset(0, 16).ClearContents
End If
End If
exitHandler:
Application.EnableEvents = True
Exit Sub
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 4 Then
Cancel = True
Set CopyCell = Target
End If
If Not Intersect(Target, Range("P4:P201,R4:R201")) Is Nothing Then
Cancel = True
Target.Formula = Now()
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not CopyCell Is Nothing Then
If Not Intersect(ActiveCell, Range("V61:V66, X60:X66")) Is Nothing Then
ActiveCell.Value = CopyCell.Value
Range("W" & ActiveCell.Row).Value = CopyCell.Offset(, 7).Value
Set CopyCell = Nothing
End If
End If
End Sub


Sub Clearcells()
'Updateby Extendoffice 20161008
Range("D4", "D201").ClearContents
Range("E4", "E201").ClearContents
Range("F4", "F201").ClearContents
Range("I4", "I201").ClearContents
Range("J4", "J201").ClearContents
Range("K4", "K201").ClearContents
Range("L4", "L201").ClearContents
Range("M4", "M201").ClearContents
Range("N4", "N201").ClearContents
Range("O4", "O201").ClearContents
End Sub
Sub AreYouSure()
Dim Sure As Integer
Sure = MsgBox("Are you sure?", vbOKCancel)
If Sure = 1 Then Call Clearcells
End Sub
Sub Clearlabels()
'Updateby Extendoffice 20161008
Range("V40,W40,Y40,W41,Y41,V43,X43,V45,X45,X47,X49,W51,X51,V55,W55,Y55,W56,Y56,X58,W67,W67").ClearContents
Range("V60", "V66").ClearContents
Range("W60", "W66").ClearContents
Range("X60", "X66").ClearContents
Range("Y60", "Y66").ClearContents
End Sub
Sub PrintLabel()
Range("Print1").PrintPreview
End Sub
Sub PrintMultilabel()
Range("Print2").PrintPreview
End Sub
 
Upvote 0
Can you please check what is going wrong?
Not really because ..
- I don't have your data
- I don't know what all that code is supposed to do
- I don't know which line is causing the error
- I don't know what you were doing (selection, double-click, worksheet change etc) or where you were working when the error occurred
- I don't have a sheet called BAYS or know what is on such a sheet
- I can't easily read your code because you have not used code tags (see my signature block below) to preserve any code indentation.
etc.
 
Upvote 0
Hi again me
The error comes on because of Option Explicit on this sheet. Can you please modify the code to work with Option Explicit?

Thanks
 
Upvote 0
Hi again me
The error comes on because of Option Explicit on this sheet. Can you please modify the code to work with Option Explicit?

Thanks
Refer to all 3 sections of code in post 25

In future, if posting code, please make sure your code is indented and use Code Tags to preserve that indentation. My signature block below shows how.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,633
Members
452,661
Latest member
Nonhle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top