Using Excel VBA to Select a filtered range where results will vary -
i working spreadsheet produce report. data vary depending on department reporting. need select records in column result of filter , paste them in column b, once pasted need clear cells in column remove filter. have been able accommodate variable criteria filter; however, problem selecting variable range. data selected never start in cell a2, cell after fair game. how select range varies? how have user interact macro select cells?
this works me filter variables.
cells.select selection.autofilter activesheet.range("$a$1:$f$65000").autofilter field:=1, criteria1:=array( _ "1000", "1001", "1005", "zbil", "1002", "1003", "1004", "1006", "1007", "1008", "1009", "aoms", "asps", "natl", "zcon", "zrep"), operator:=xlfiltervalues on error resume next
i using following select range, first line works select data copied (although still selects cell a1 , prefer not have cell selected). second line returns error "object doesn't support property or method. have tried range select toright end entire sheet selected.
range(activecell, activecell.end(xldown)).select selection(selection, selection.xltoright).select selection.fillright
i appreciate assistance available.
it might not efficient solution, can loop through cells/rows , check if filter hid them:
dim lastrow integer dim integer activesheet lastrow = .cells(rows.count, 1).end(xlup).row = 3 lastrow if .rows(i).hidden = false .cells(i, 2).value = .cells(i, 1).value .cells(i, 1).value = "" end if next end
Comments
Post a Comment