Copy selection Problem

JC2710

Board Regular
Joined
Mar 10, 2008
Messages
164
Hi

I am trying to copy a selection from one sheet to another.

When a user selects two entire rows that are seperate (eg row 4 and row 10) I want to copy them to a new sheet but only copy columns 3 to 7 of the rows.

Am having problems. It only seems to copy first row of selection.

Any ideas?

Thanks
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
This worked for me:

Code:
Sub Test()
    Dim r As Range
    Dim Rng As Range
    With Selection
        For Each r In .Rows
            If Rng Is Nothing Then
                Set Rng = r.Cells(1, 3).Resize(, 5)
            Else
                Set Rng = Union(Rng, r.Cells(1, 3).Resize(, 5))
            End If
        Next r
    End With
    Rng.Copy Worksheets("Sheet2").Range("A1")
End Sub

The code does not check that entire rows are selected.
 
Upvote 0

Forum statistics

Threads
1,203,687
Messages
6,056,746
Members
444,888
Latest member
Babi_mn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top