Macro non Contiguous Range

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
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
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
With ActiveSheet.Range("B6:J" & Lastrow & ",R6:R" & Lastrow)
 
Upvote 0

Forum statistics

Threads
1,213,550
Messages
6,114,265
Members
448,558
Latest member
aivin

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