excel - VBA copy paste code only returns first hit from specified criteria -
i trying copy rows 1 excel sheet using criteria. desired result: vba code finds matches , pastes them without spaces table. when user changes criteria , hits run, old results removed , new list matching criteria appears.
i have following code. when run though first record matches criteria appears. help! doing wrong?!
'module search wards' records match ward name specified in drop-down menu sub findward() dim wardname string dim finalrow integer dim integer sheets("ward_rank_table").range("b7:bc157").clearcontents wardname = sheets("ward_rank_table").range("b3").value finalrow = sheets("ward_rank_set").range("b160").end(xlup).row sheets("ward_rank_set").select = 2 finalrow if cells(i, 2) = wardname range(cells(i, 2), cells(i, 55)).copy sheets("ward_rank_table").select range("b7").end(xlup).offset(1, 0).resize(1, 55).pastespecial xlpasteformulasandnumberformats end if next range("b3").select end sub
try: sheets("ward_rank_set").select finalrow = activesheet.usedrange.rows.count
Comments
Post a Comment