excel - Array VBA code (Data Extraction) -
current;y working on extracting data (rows) based on criteria userform code below work on individual sheets once button available on sheet can code below work , writes "slave" sheet expected, cannot life of me correct complied code arrays.
i've tried different code various places including here i'm not competent enough debug fault.
could me out here, or point me in right direction?
sub commandbutton1_click() dim strsearch string, lastline integer, tocopy integer strsearch = cstr(inputbox("enter string search for")) 'enter code sheets in here... lastline = range("a65536").end(xlup).row j = 1 = 1 lastline each c in range("a" & & ":z" & i) if instr(c.text, strsearch) tocopy = 1 end if next c if tocopy = 1 rows(i).copy destination:=sheets("slave").rows(j) j = j + 1 end if tocopy = 0 next end sub
there faster ways adding in sheet looping
sub commandbutton1_click() dim strsearch string, lastline long dim sht worksheet strsearch = cstr(inputbox("enter string search for")) j = 1 each sht in thisworkbook.worksheets if sht.name <> "slave" lastline = sht.cells(rows.count, 1).end(xlup).row = 1 lastline each c in sht.range("a" & & ":z" & i) if instr(c.text, strsearch) sht.rows(i).copy destination:=sheets("slave").rows(j) j = j + 1 exit 'stop looking! end if next c next end if next sht end sub
Comments
Post a Comment