View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
damorrison[_2_] damorrison[_2_] is offline
external usenet poster
 
Posts: 38
Default Change cell value when right-clicked/double-clicked

sure, here you go

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

'sets the range for code to work in, this one works only in column A

If Union(Range("$A:$A"), Target).Address = Range("$A:$A").Address Then

' selects the active cell and then moves 10 columns to the right,
selects that cell and copies it

ActiveCell.Offset(0, 10).Range("A1").Select
Selection.Copy

'moves back to the left 10 columns and pastes

ActiveCell.Offset(0, -10).Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False

'moves down to the cell below

ActiveCell.Offset(1, 0).Range("A1").Select
End If


End Sub

right click on the sheet tab, select view code, from the dropdown menu
where it says ,general, select worksheet, enter the code above
Dave