Hey Guys,
I am very very new to VBA. I am trying to figure out way where a user clicks on a cell, the information in that cell is copied and pasted to another cell in the same worksheet. Thanks for any help.
Hey Guys,
I am very very new to VBA. I am trying to figure out way where a user clicks on a cell, the information in that cell is copied and pasted to another cell in the same worksheet. Thanks for any help.
Try:
[vba]Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Rows.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
Target.Copy Range("B1")
End If
End Sub[/vba]
If the user clicks on any cell within A1:A10 the cell will be copied to B1
[VBA]Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Target.Copy Application.InputBox("Give destination cell ...", _
"Place copied cell where ?", Type:=8)
Cancel = True
End Sub[/VBA]
Hello Reafidy, Thanks for the code, it work great. There is one other thing I forgot to mention... Say the range is B1:B10, but I want to copy the data from cell A1:A10 to cell C1. So for example, the user click on B1, the data from A1 is copied over to C1.
Try:
[VBA]
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Rows.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("B1:B10")) Is Nothing Then
Target.Offset(, -1).Copy Target(, 2)
End If
End Sub
[/VBA]