Excel VBA: How to Unfilter Only One Autofilter Range at a Time? Code Provided -


thanks coming thread.

what have:

-a report autofilter on rows a:g

what need:

-circumstantial code unfilters specific column if there filter on it.

-running code below unfilters entire range of a:g.

-in instance, want "f" unfiltered, leaving other filters alone if filtered.

with sheets("data")     if .range("f1").autofilter = true         activesheet.range("$a$1:$g$59826").autofilter field:=6     else     end if end 

any , ideas appreciated! thank much!

try this:

sub unfilter() dim ws excel.worksheet  set ws = worksheets("data") ws     if .autofiltermode = true         if not intersect(.autofilter.range, .range("g1")) nothing             .range("$a$1:$g$59826").autofilter field:=.range("g:g").column         end if     end if end end sub 

this line in code:

if .range("f1").autofilter = true 

... turns off filtering whole sheet. instead code checks if sheet filtered with:

if .autofiltermode = true 

it checks if filter includes column g with:

if not intersect(.autofilter.range, .range("g1")) nothing 

i made couple of changes make code little more flexible. enables intellisense ws object, helpful. (i find various filter-related properties , methods confusing, without auto-completion.)


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -