Macro non Contiguous Range

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,527
I have code to use advanced auto filter to extract data from range B6:J & R6:R

Code:
 With ActiveSheet.Range("B6:J,R6:R" & Lastrow)

I get application defined or object defined error and the code above is highlighted

It would be appreciated if someone could assist me



Sub Extract()

Code:
 Sheets("Imported Data").Select
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row

With ActiveSheet.Range("B6:J,R6:R" & Lastrow)
.AutoFilter Field:=1, Criteria1:=Array("DM", "RK"), Operator:=xlFilterValues
.AutoFilter Field:=2, Criteria1:=Array("P1", "LX"), Operator:=xlFilterValues

.SpecialCells(xlCellTypeVisible).Copy Worksheets("Sales by Region").Range("A2")
.AutoFilter
End With


End Sub
 

Some videos you may like

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

footoo

Well-known Member
Joined
Sep 21, 2016
Messages
2,945
Office Version
2016
Platform
Windows
With ActiveSheet.Range("B6:J" & Lastrow & ",R6:R" & Lastrow)
 

Watch MrExcel Video

Forum statistics

Threads
1,095,783
Messages
5,446,477
Members
405,403
Latest member
horace james

This Week's Hot Topics

Top