if user filter then

Vanda_a

Well-known Member
Joined
Oct 29, 2012
Messages
923
Dear all

May I know why my code doenst work. Any thing that I mislead?
My data is in filtermode but I havent filter anything yet. I want if i filter something then A1 = A
Code:
Private Sub Worksheet_Change(ByVal target As Range)

If ActiveSheet.AutoFilter Field:=1, Criteria1:="<>" Then

Range("A") = A

End If

End Sub

Thank you for your help
 
Last edited:

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

CodeNinja

Well-known Member
Joined
Feb 18, 2013
Messages
634
Hi Vanda_3,
I think the problem with your code lies in Range("A") = A... First, you cant select range("A")... you could select range ("A:A") which would select the column A... Second you are setting it to A which is an unknown variable... maybe you want range("A1") = "A" or even range("A:A") = "A" or you want to set a variable for A and set the range to that variable....

Also of note: If you have your filter on, but nothing on the sheet is filtered, activesheet.filtermode will return false...

Hope this helps,

CN
 

Vanda_a

Well-known Member
Joined
Oct 29, 2012
Messages
923
mistake on writing.

i meant Range("A1")

Although i change to below one still not work
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If ActiveSheet.FilterMode = True Then

Range("A1") = "A"

End If

End Sub
I have tried record macro to see what that the code is. I got this
Code:
ActiveSheet.AutoFilter Field:=1, Criteria1:="<>
but i cant get it work correctly

Code:
If ActiveSheet.AutoFilter Field:=1, Criteria1:="<> then
 
Last edited:

Vanda_a

Well-known Member
Joined
Oct 29, 2012
Messages
923
I have my filter on but i dont filter anything yet. and when i filter something, i want the code is trigered
 

Watch MrExcel Video

Forum statistics

Threads
1,123,057
Messages
5,599,545
Members
414,316
Latest member
ExcelLee

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
Top