PDA

View Full Version : Move cells to another worksheet



Romulo Avila
08-22-2017, 12:18 PM
Good afternoon everyone,


I need a VBA code where I can on Sheet1 select a cell and by giving 02 clicks it moves the contents of the selected cell plus 02 cells to the right for Sheet2.
Example: If I have cell A10 selected and give 2 clicks move the range A10: C10 to sheet2, remembering that on sheet2 it should be stored below the last line.


Thank you one more time.

offthelip
08-22-2017, 02:42 PM
if you put this routine in the sheet 1 before double click it should work;


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim inarr As Variant
With Worksheets("sheet2")
inarr = Target.Resize(, 3)
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range(.Cells(lastrow + 1, 1), .Cells(lastrow + 1, 3)) = inarr

End With
End Sub

Romulo Avila
08-22-2017, 04:37 PM
Good evening,

It would be like giving 2 clicks to move the content to Sheet2, adding after the last line filled.


Thanks a lot for the help