View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default How to run this macro

This is worksheet event code which runs when any cell is double-clicked.

As written it does nothing. Copying a value without doing something with it
throws an error in this code.

If you rem out the On Error Resume Next you would see it crashes on
Target.Value.Copy

Try this version so's you can see how the event will work. See how the
double-clicked cell value is copied three columns to the right on same row.

Private Sub Worksheet_BeforeDoubleClick(ByVal _
Target As Range, Cancel As Boolean)
On Error Resume Next
If Target.Value < "" Then
Target.Copy Destination:=Target.Offset(0, 3)
End If
Cancel = True
End Sub

Right-click on your sheet tab and "View Code" Copy/paste the above into that
sheet module.

Here's another set of code that brings a value into the double-clicked cell.

Private Sub Worksheet_BeforeDoubleClick(ByVal _
Target As Range, Cancel As Boolean)
On Error Resume Next
If Target.Value < "" Then
Target.Value = Target.Offset(0, 4).Value
End If
Cancel = True
End Sub


Gord Dibben MS Excel MVP

On 19 Mar 2007 13:32:46 -0700, wrote:

Hello,

would anybody please tell me steps how to run this macro:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
On Error Resume Next
If Target.Value< "" Then
Target.Value.Copy
End If
Cancel = True
End Sub

and how does it work?

thanks