excel - Filtering based on previous filter -


using code have set using filters work in correlation userforms checkboxes choose filter. if filter on 1 variable utilities filters, if move filter clients , filter instead of giving me clients associated specific utility filtered clears , filters on clients.

i thinking solution may have deal method: .specialcells(xlcelltypevisible)

private sub cancel_uf_click()     utilityfilter.hide     range("a1").select end sub  private sub confirm_uf_click()     activesheet.unprotect ("umc626")     clearfilter     updatefilters     utilityfilter.hide     application.screenupdating = false     range("a1").select     activesheet.protect password:="umc626", _                         drawingobjects:=false, _                         contents:=true, _                         scenarios:=true end sub  sub selectall_uf_click()     if selectall = true         electricty_uf.value = true         gas_uf.value = true         nonutility_uf.value = true         solarelectricity_uf.value = true         solarthermal_uf.value = true         solidwaste_uf.value = true         water_uf.value = true     else         electricity_uf.value = false         gas_uf.value = false         nonutility_uf.value = false         solarelectricity_uf.value = false         solarthermal_uf.value = false         solidwaste_uf.value = false         water_uf.value = false     end if end sub  sub updatefilters()     integer_uf = -1      if electricity_uf.value = true         add_uf string_uf, "e"         range("e6:e67").autofilter field:=1, _                                    criteria1:=string_uf, _                                    operator:=xlfiltervalues     end if      if gas_uf.value = true         add_uf string_uf, "g"         range("e6:e67").autofilter field:=1, _                                    criteria1:=string_uf, _                                    operator:=xlfiltervalues     end if      if nonutility_uf.value = true         add_uf string_uf, "nu"         range("e6:e67").autofilter field:=1, _                                    criteria1:=string_uf, _                                    operator:=xlfiltervalues     end if      if solarelectricity_uf.value = true         add_uf string_uf, "se"         range("e6:e67").autofilter field:=1, _                                    criteria1:=string_uf, _                                    operator:=xlfiltervalues     end if      if solarelectricity_uf.value = true         add_uf string_uf, "se"         range("e6:e67").autofilter field:=1, _                                    criteria1:=string_uf, _                                    operator:=xlfiltervalues     end if      if solarthermal_uf.value = true         add_uf string_uf, "st"         range("e6:e67").autofilter field:=1, _                                    criteria1:=string_uf, _                                    operator:=xlfiltervalues     end if      if solidwaste_uf.value = true         add_uf string_uf, "sw"         range("e6:e67").autofilter field:=1, _                                    criteria1:=string_uf, _                                    operator:=xlfiltervalues     end if      if water_uf.value = true         add_uf string_uf, "w"         range("e6:e67").autofilter field:=1, _                                    criteria1:=string_uf, _                                    operator:=xlfiltervalues     end if end sub  sub add_uf(string_uf() string, newvalue string)     integer_uf = integer_uf + 1     redim preserve string_uf(integer_uf)     string_uf(integer_uf) = newvalue end sub 

i think focus should on add_uf calling newvalue. there anyway sort column after has been sorted? can see in picture below i'd beable sort 1 colum. on energy after sort on work type. enter image description here

i not intend re-write code can provide information, , methods, need achieve want.

currently focusing on single column:

range("e6:e67").autofilter field:=1, _ 

you should extend whole table area:

activesheet.range("$a$5:$m$112").autofilter field:=6, criteria1:="leeds" 

the number 6 sixth column within filter range. might create range reference refer filter-range:

dim rngfilter range set rngfilter = worksheets("staff list").autofilter.range 

the filters accumulate, following filter on 2 columns:

activesheet.range("$a$5:$m$112").autofilter field:=6, criteria1:="leeds" activesheet.range("$a$5:$m$112").autofilter field:=7, criteria1:="sales" 

at point clear filters:

activesheet.showalldata 

clearing single filter applying filter no criteria:

activesheet.range("$a$5:$m$112").autofilter field:=7 

if record macro sort on more 1 column (using custom sort) creates code following, i've added comments:

'clear previous sort activeworkbook.worksheets("staff list").autofilter.sort.sortfields.clear  'accumulate sortfields activeworkbook.worksheets("staff list").autofilter.sort.sortfields.add key:= _     range("c6:c112"), sorton:=xlsortonvalues, order:=xlascending, dataoption _     :=xlsortnormal activeworkbook.worksheets("staff list").autofilter.sort.sortfields.add key:= _     range("b6:b112"), sorton:=xlsortonvalues, order:=xlascending, dataoption _     :=xlsortnormal  'apply sort activeworkbook.worksheets("staff list").autofilter.sort     .header = xlyes     .matchcase = false     .orientation = xltoptobottom     .apply end 

recording macros reveal other methods , properties may useful you. recorded code not elegant, , can reduced (tidied) significantly, provide useful information.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -