VBA - copy & paste from a cell on one worksheet to another worksheet by double clicking

simo2509

New Member
Joined
Feb 26, 2016
Messages
5
Hi All,

I have a spreadsheet with two worksheets. what i would like to do is when a cell within column D on worksheet 2 for example is double-clicked on, it will copy the data from that cell into cell B2 on worksheet 1.

Likewise, if possible, I would like to make it so that double clicking on a different cell in the same column will automatically replace the data that is in B2 on WS1, rather than having to physically delete the data in cell B2 on WS1 before being able to add other data.

I cant see any other way of doing this without VBA, which the only experience of using it I have, is that I have used it in this sentence.

Any sort of help on this would be greatly appreciated.

Cheers,

Liam
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Right click on the Sheet2 tab and select "View Code". Paste this in there:

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

If Target.Count = 1 And Target.Column = 4 Then
    Sheets("Sheet1").Range("B2").Value = Target.Value
    Cancel = True
End If

End Sub

WBD
 
Upvote 0

Forum statistics

Threads
1,216,776
Messages
6,132,660
Members
449,744
Latest member
kauamarcosms

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