In Excel 07. Copy to second cell by clicking f8irst?
First question...........copy contents to a cell
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const myRange As String = "A1:A10"
'change to "A:A" for the column
On Error GoTo endit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(myRange)) Is Nothing Then
If Target.Value < "" Then
Target.Offset(0, 1).Value = Target.Value
End If
End If
endit:
Application.EnableEvents = True
End Sub
Second question.............combine contents with contents of another cell
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const myRange As String = "A1:A10"
'change to "A:A" for the column
On Error GoTo endit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(myRange)) Is Nothing Then
If Target.Value < "" Then
With Target.Offset(0, 1)
.Value = .Value & Target.Value
End With
End If
End If
endit:
Application.EnableEvents = True
End Sub
Note: you can't have two selectionchange events in the same worksheet.
You could change one of them to a BeforeDoubleClick event.
Gord Dibben MS Excel MVP
On Mon, 3 Dec 2007 15:52:00 -0800, Pgrudin
wrote:
I would like each cell in a column to duplicate the contents of each cell in
another column, but only when the latter (which already has contents) is
clicked. Is this possible? If so, can I install it and then use fill-down to
make the whole column work this way?
Can I do something like this but have the contents of one cell added to the
contents of a second cell on mouse-clicking the first?
Thanks.
|