excel - Lookup Value in Same Column on Multiple Worksheets -
in column b on 3 (bakery, floral, grocery) of 5 sheets in workbook, want find rows have word flyer
in column b. there multiple rows in each worksheet have word flyer
in column b. when finds word flyer
, paste entire row sheet1.
i go work on 1 tab, want same code search 3 tabs (but not 5 ... issue) , paste of rows word flyer
in column b sheet1.
my code (works, on bakery tab):
sub copyrowsflyer() 'this looks in bakery tab , moves has "flyer" in column b sheet 1 dim bottomb integer dim x integer bottomb = sheets("bakery").range("b" & rows.count).end(xlup).row: x = 1 dim c range each c in sheets("bakery").range("b3:b" & bottomb) if c.value = "flyer" c.entirerow.copy worksheets("sheet1").range("a" & x) x = x + 1 end if next c end sub
similar other solutions posted. pretty simple. replaces bounding range checking. fewest variables. no mid-execution dimensioning.
sub copyrowsflyer() dim strsh variant, c range, x integer x = 1 each strsh in array("bakery", "floral", "grocery") each c in worksheets(strsh).range("b:b") if c = "" , c.row > 2 exit elseif c = "flyer" , c.row > 2 c.entirerow.copy worksheets("sheet1").range("a" & x) x = x + 1 end if next next end sub
Comments
Post a Comment