That code needs to go into a worksheet's code module. Easy way to get there
is to choose the sheet and then Right-click on the sheet's name tab and
choose [View Code] from the list that appears. Copy the code and paste it
into the module that you see. Close the VB Editor.
Type something into a cell on the sheet and then double-click it. You won't
see much happen other than perhaps the cell changing to indicate it is being
copied. Click another cell and use [ctrl]+[v] or Edit | Paste and the
contents of the other cell will be pasted into it.
What happens is that when you double-click a cell in a worksheet an 'event'
is triggered (the double-click event). By having code in the worksheets
_BeforeDoubleClick event handler, Excel says "before I do what I would
normally do with a double-click, I should do whatever is in this code
segment".
In the routine 'Target' is the cell or range of cells that were acted on.
Think of it as a mirror image of the cell itself.
On Error Resume Next says that if something I'm trying to do here can't be
done, ignore my mistake and just keep on trying and running the code.
If there is something in the cell, it is copied to the clipboard, if there
isn't any visible text of some type in the cell, nothing gets copied to the
clipboard.
Finally, the Cancel=True statement says "oops, he really didn't mean to
actually double-click the cell, he just wanted a slick way of copying to the
clipboard, so don't do what you normally would have done when a cell is
double-clicked (which is to go into edit mode in the cell).
By the way, because the copy command is given as Target.Value.Copy when you
paste the information it will be much the same as if you'd done a copy from
the keyboard and then used Edit | Paste Special with [Values] chosen as the
option.
And that's how it works.