excel - Remove current cell's value from active autofilter in same column -
i have big excel sheet containing +100k rows , have autofilter on 1 column of text values category numbers , descriptions. there thousands of different values in column f, updating autofilter impractical via using standard ui.
how can create macro removes active cell's value autofilter active on same column?
with of expert, came working solution case.
just posting solution others:
sub clear_filter_and_value() application.screenupdating = false application.displayalerts = false dim w worksheet dim filterarray() dim currentfiltrange string dim col integer dim flag boolean set w = activesheet if w.autofiltermode = false selection.autofilter flag = false on error goto exit1 w.autofilter currentfiltrange = .range.address .filters f = 1 .count .item(f) if .on if activecell.column = f redim filterarray(1 .count) if .count = 2 filterarray(1) = .criteria1 filterarray(2) = .criteria2 else filterarray(1) = .criteria1 end if end if elseif activecell.column = f tr = cells(rows.count, activecell.column).end(xlup).row redim filterarray(1 tr - 1) = 2 tr filterarray(i - 1) = cells(i, activecell.column).value flag = true next end if end next f end end w.autofiltermode = false j = 1 redim newarray(1 ubound(filterarray)) if flag = false on error goto 1 = 1 ubound(filterarray(1)) on error goto 1 if instr(1, filterarray(1)(i), activecell.value) = 0 newarray(j) = filterarray(1)(i) j = j + 1 end if next else 1: err.clear = 1 ubound(filterarray) if instr(1, filterarray(i), activecell.value) = 0 newarray(j) = filterarray(i) j = j + 1 end if next end if col = 1 1 if not isempty(filterarray(1)) w.range(currentfiltrange).autofilter field:=activecell.column, criteria1:=newarray, operator:=xlfiltervalues end if next col exit1: application.screenupdating = true application.displayalerts = true end sub
Comments
Post a Comment