Copy contents of specific cell to the active cell

Hudco

Board Regular
Joined
Jan 4, 2006
Messages
131
Office Version
  1. 365
Hi Everyone,

I am trying to set VBA to set the current cell that I have clicked on as the cell with focus and copy the contents of a specific cell to that cell.

That is, my current selection might be B5 and I want to copy the contents of G6 to B5. B5 is the cell that will change depending on what cell I "click" on.

I have tried iterations of Range() and Set Focus but this seems to be above my knowledge/learning.

Any answers?

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
You can try the below code in your worksheet module :
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Target.Value = Range("G6").Value
End Sub
 
Upvote 0
You can try the below code in your worksheet module :
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Target.Value = Range("G6").Value
End Sub
Thanks Sanjeev,

I just worked it out now - I wanted the formula's as well and that was where my coding was wrong.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,726
Members
452,939
Latest member
WCrawford

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