Help me modify this Double Click VBA

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,

i have this VBA code which if a cell in the range E8:AF10 is clicked, the cell value is copied to Sheet 2 - B3

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)If Not Intersect(Target, Range("E8:AF10")) Is Nothing Then
    Cancel = True
    Target.Copy
    Sheets("Sheet2").Range("B3").PasteSpecial Paste:=xlPasteValues
End If
End Sub

Now instead of copying the clicked cell i want it to copy 2 things:
Value in Row 6 of the current cell
example: If cell F9 is clicked > copy cell F6

Value in Column AI of the current cell
example: If F9 is clicked > copy cell AI9

Appreciate any help
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
How about
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("E8:AF10")) Is Nothing Then
    Cancel = True
    Cells(6, Target.Column).Copy
    Sheets("Sheet2").Range("B3").PasteSpecial Paste:=xlPasteValues
    Range("AI" & Target.Row).Copy
    '???
End If
End Sub
 
Upvote 0
How about
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("E8:AF10")) Is Nothing Then
    Cancel = True
    Cells(6, Target.Column).Copy
    Sheets("Sheet2").Range("B3").PasteSpecial Paste:=xlPasteValues
    Range("AI" & Target.Row).Copy
    '???
End If
End Sub

thanks for the quick reply, working perfectly :)
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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