Home » excel » excel – I need to copy multiple user selected rows to a different worksheet. The problem is, the selected rows are different each time the macro runs

excel – I need to copy multiple user selected rows to a different worksheet. The problem is, the selected rows are different each time the macro runs

Posted by: admin May 14, 2020 Leave a comment

Questions:

Say the user selected E3 and E4, is there a way to copy the values of E3 and E4, as well as the next three cells on their right (F3:H4)?

I tried using ActiveCell.Resize but I do not know how to copy selected rows since the selected rows change depending on the user.

This is a sample of my code:

ActiveCell.Resize(, 4).Copy Destination:=Worksheets("Sheet3").Range("b7:e14")
How to&Answers:

Use Selection instead of ActiveCell.

Selection contains all selected cells while ActiveCell is always only one cell within the whole Selection.

In the following example Selection would be Range("A2,B5,A7,A10:B10") but ActiveCell would be Range("A10").

enter image description here