Copy Cell Content on Click

excelnow

Board Regular
Joined
Nov 17, 2009
Messages
106
Hi,

I am not sure if this is possible because I couldn't find anything about this on the web and on this forum.

I want to copy the cell content(text) when I click on it. Can this be done via code?

Thanks
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
This will copy the contents of whatever single cell you click in the specified range, into the clipboard buffer. You only have to click it once and it will automatically be copied. You will then have to paste it somewhere outside the chosen range.

The flashing cell showing you have copied that cell, keeps flashing of course until you push escape or copy an other cell in the worksheet.

If you are doing a lot of single cell copying then all you have to do is get your Ctrl-V fingers ready to paste after clicking each chosen cell. Or right click to paste.

Can paste into other spreadsheets or even non-Excel programs because it is copied into the computer clipboard buffer, ready to paste anywhere.
Code:
Sub Worksheet_SelectionChange(ByVal Target As Range) 'single click version
 
    If Intersect(Target, Range("B2:G10")) Is Nothing Then Exit Sub
    ActiveCell.Copy
 
End Sub
 
Upvote 0
The above code will keep flashing your cell that you have copied to clipboard when you click any cell in range. Instead of pushing escape key to stop the flashing, below code is modified so that the flashing is stopped and clipboard is cleared whenever you click anywhere outside the chosen range.

It is like pushing the escape key when a click is done outside range.

Reason I modified code was original code would keep flashing in the middle of some merged cells text that I could not read. Now easier for me to click than find the escape key.
Code:
Sub Worksheet_SelectionChange(ByVal Target As Range) 'single click version
 
    If Intersect(Target, Range("B2:G10")) Is Nothing Then
        Application.CutCopyMode = False   'clears clipboard and stops cell flashing - like pushing escape key
        Exit Sub
    Else
        ActiveCell.Copy
    End If
 
End Sub
 
Last edited:
Upvote 0
This is _exactly_ what I've been looking for, good work.

Unfortunately I have little idea what I'm doing with VB, I'm a humble ksh scripter.

I followed some MS instructions on setting up a macro in excel but it doesn't seem to do anything.
Could I beg a step by step numpty guide to getting this to work?

I don't really want to learn too much about this stuff, I just really need the functionality and have colleagues who are eager to get their hands on it too.

Thanks so much for your time.
 
Upvote 0
Hi Guys,

I'm using this script to copy text only into memory and paste it into a program called "VCI". It seems to work but only after the first two attempts. Anything else I try to paste afterwards will not paste!

However, if I manually quadruple click the cell, hightlight text, copy and then paste it will work but I want to reduce the number of clicks down to one. I'm stumpted on this one, I have a feeling it could be the program I'm pasting into.

Anyone have any ideas or perhaps a different script that does the same thing?

I can't count the number of times I've gotten great help from everyone here-this is an AWESOME forum.

Thank you!

ps: unixanalyst,

-open macro editor
-paste code into edit code window
-define your cell range
-click the run icon
 
Upvote 0
I tried this code below but still got same problem:

Sub Worksheet_SelectionChange(ByVal Target As Range) 'single click version

If Intersect(Target, Range("A1:J281")) Is Nothing Then Exit Sub
ActiveCell.Select
ActiveCell.Copy

End Sub
 
Last edited:
Upvote 0
Hi MrExcel,

Thanks for your reply, I tried the following after reading the link you posted (bare in mind, I have no clue what I'm doing):

Sub Singleclick(ByVal Target As Range) 'single click version

If Intersect(Target, Range("A1:J281")) Is Nothing Then Exit Sub

Dim DataObj As New MSForms.DataObject
Dim S As String
S = "ActiveCell.Select"
DataObj.SetText S
DataObj.PutInClipboard

Dim DataObj As New MSForms.DataObject
Dim S As String
DataObj.GetFromClipboard
S = DataObj.GetText
Debug.Print S

End Sub


It seemed to be copying the text into clipboard, I see the results but it's still not pasting in to the other program I'm using. I also selected a whack load of references too. Any further help would be appreciated, I feel we're getting close! lol
 
Upvote 0

Forum statistics

Threads
1,225,137
Messages
6,183,080
Members
453,146
Latest member
Lacey D

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