need a macro to copy current selection. Please help!

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi,

I am not sure if this is posible?
In sheets("Data").range (I43:I53), if I click on any of the cell can I make the macro to just copy value of that cell
so that I dont have to ctrl+c and is ready to be pasted somewhere...

Thanks for helping.
Pedie;)
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
It would be a real simple macro, only needs one line:

Selection.Copy
 
Upvote 0
Actually I think they're saying if you click within a certain group of cells, have it automatically copy just the value to the clipboard.


Maybe the solution would be a macro that placed a button over those cells displaying the value of the cell that when clicked would automatically copy that value into the clipboard.
 
Last edited:
Upvote 0
Perhaps in the sheet's code module

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("I43:I53")) Is Nothing Then Target.Copy
End Sub
 
Upvote 0
Reading your comments and going back and reading the original question, you are probably right. I didn't get exactly what they were asking the first time around.
 
Upvote 0
Modified Vog's solution in case you have a formula and don't want to paste the formula:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim DataObj As New MSForms.DataObject
Dim S As String
If Not Intersect(Target, Range("I43:I53")) Is Nothing Then
     Target.Select
     tobepasted = ActiveCell.Text
     DataObj.SetText tobepasted
     DataObj.PutInClipboard
End If
End Sub

Of course it won't show that it has just copied that cell, but it does copy it to the clipboard.
 
Upvote 0
For that to work you'll need to create a reference to Microsoft Forms 2.0 Object Library in Tools > References ;)
 
Upvote 0

Forum statistics

Threads
1,214,854
Messages
6,121,941
Members
449,056
Latest member
denissimo

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