Filter Issue

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Filter Issue

Post by adeel1 »

Hello All

i Col A there is data and in Col E the data i want to apply filter like array("A1","A8","A18"), possible?

i can hide rows with VBA but i want to know in this way. please

Code: Select all

Sub nbd()

'xx = Range("data")

xx = Join(Application.Transpose(Selection), ",")
ActiveSheet.Range("a1").AutoFilter field:=1, Criteria1:=xx, _
  Operator:=xlFilterValues

End Sub
Adeel
You do not have the required permissions to view the files attached to this post.

snb
4StarLounger
Posts: 584
Joined: 14 Nov 2012, 16:06

Re: Filter Issue

Post by snb »

Code: Select all

Sub nbd()
  ActiveSheet.usedrange.autofilter 1, Application.Transpose(Selection),7
End Sub

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Re: Filter Issue

Post by adeel1 »

thx snb sir , for your quick reply, its working :clapping: :thankyou:

i am facing strange issue that when i run filter code 3 to 4 times then its isnot allowed me to select range after i need to close file forcefully and restart excel. any idea why this is happening..

Adeel

snb
4StarLounger
Posts: 584
Joined: 14 Nov 2012, 16:06

Re: Filter Issue

Post by snb »

Maybe

Code: Select all

Sub nbd()
  on error resume next
  ActiveSheet.usedrange.autofilter
  ActiveSheet.usedrange.autofilter 1, Application.Transpose(Selection),7
End Sub

adeel1
3StarLounger
Posts: 264
Joined: 04 Oct 2017, 15:47

Re: Filter Issue

Post by adeel1 »

thx SNB sir for your help and reply.. :cheers: :thankyou: