AutoFilter mehod of Range class failed

kohatian

New Member
Joined
Jun 12, 2015
Messages
2
Hello,
I have an excel file where I am trying to filter range of rows based on a macro but get an error: 'AutoFilter mehod of Range class failed'. Below is the macro code I am using:
Sub Button1_Click()

With ActiveSheet()
.AutoFilterMode = False
.Range("B12:B48").AutoFilter
.Range("B12:B48").AutoFilter Field:=2, Criteria1:=Range("B12:B48").Value

End With
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You are using the entire range as your criteria....what do you want to filter by ??
Code:
Sub Button1_Click()

With ActiveSheet()
.AutoFilterMode = False
.Range("B12:B48").AutoFilter
.Range("$B$12:$B$48").AutoFilter Field:=1, Criteria1:=' a separate range like Range("B4").Value OR a value like "bob" or a number
End With
End Sub
 
Upvote 0
As I said I want to filter that range of rows and I want rest to be hidden which I click on this button.
 
Upvote 0
But filter for what ??
What is the item you are filtering for ???
 
Upvote 0

Forum statistics

Threads
1,202,987
Messages
6,052,938
Members
444,616
Latest member
novit19089

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