Seeking method to copy non-contiguous columns with LastRow range method

auto.pilot

Well-known Member
Joined
Sep 27, 2007
Messages
734
Office Version
  1. 365
Platform
  1. Windows
As the title says, I am seeking to copy a non-contiguous range of cells in columns that are identified by code using Lr (LastRow).

The following works, because only the range of B6:C37 and H6:H37 are copied.

Code:
Sub CopyNonContRange()

    
    Range("B6:C37,H6:H37").Copy

End Sub

When using Lr, this does not work... Instead, the range of B6:H37 is copied.

The last row of data in all columns is the same and their are no blank cells.

Code:
Sub CopyNonContRange2()

Dim Lr As Long
Lr = Range("B" & Rows.Count).End(xlUp).Row

    
    Range("B6:C" & Lr, "H6:H" & Lr).Copy

End Sub

How can I use both Lr and copy non-contiguous ranges?

I searched, but did not come up with anything quite like what I need.

Appreciate any thoughts.

Thanks in advance.

jim
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Try
Code:
Dim Lr As Long
Lr = Range("B" & Rows.Count).End(xlUp).Row

With Range("6:" & Lr)
    Application.Intersect(Range("A:C, H:H").EntireColumn, .EntireRow).Copy
End With
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

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