excel - How to move range values to Top after filtering using vba macro -
how move range values top after filtering using vba macro per requirement, have filtered defects severity filter lob, requirement jira in column should on top.
i not getting how move top of jira in column a.appreciate here.
note: after move severity should not altered ie. jira defect should filtered severity. per screen shot attached
sub moverange() lrow = range("a" & rows.count).end(xlup).row set mr = range("a2:a" & lrow) mr.select each cell in mr 'if cell.value = "jira" selection.entirerow.cut shift:=xlup if cell.value = "jira" selection.cut 'rows("2:2").select selection.insert shift:=xlup end if next end sub
how simple helper-column 0
"jira" , 1
not "jira" (or true
false
or whatever) , sort helper column first criteria...
or if not want change order (and "jira" @ top) use in helper column (start in row 2):
=row()+1000*(a2<>"jira")
and sort helper column.
way order stays same, except "jira" comes first , else later on.
you can use special sort order if old order doesn't matter custom sort:
sort by: column sort on: values order: custom list...
a new window pops , there need enter "jira" (without quotes) in right box , hit ok. way order normal, "jira" come first.
to via vba can whith code:
sub moverange() dim srange range activesheet.sort set srange = .parent.range("a2", .parent.range("a" & rows.count).end(xlup)) .sortfields.clear .sortfields.add srange, 0, 1, "jira", 0 .setrange srange.entirerow .apply end end sub
if still have questions, ask ;)
Comments
Post a Comment