vb.net - Create Excel array based on search function -
i've got list in excel shows titles in column , values in column b, this:
article_posno 1 article_artno 111123 article_description black pens article_posno 2 article_artno 280708 article_description yellow paper article_posno 3 article_artno 999912 article_description blue scissors
what i'm trying build vb function creates array holds values, can print this:
pos art no description 1 111123 black pens 2 280708 yellow paper 3 999912 blue scissors
below current script searches titles -> gets values next them , send msgbox of value. list, mean 9 msgboxes. ideally, show 1 messagebox article information on it.
any ideas?
many in advance!
sub findarticles() dim firstaddress string dim mysearch variant dim rng range dim long mysearch = array("article_posno", "article_artno", "article_description") sheets("sheet1").range("a1:a1000") = lbound(mysearch) ubound(mysearch) set rng = .find(what:=mysearch(i), _ after:=.cells(.cells.count), _ lookin:=xlformulas, _ lookat:=xlwhole, _ searchorder:=xlbyrows, _ searchdirection:=xlnext, _ matchcase:=false) if not rng nothing firstaddress = rng.address artvalue = rng.offset(0, 1) 'gather value right msgbox artvalue set rng = .findnext(rng) loop while not rng nothing , rng.address <> firstaddress end if next end end sub
i assume input worksheet named input
, has attributes in sequence in example, being first column names , second values.
1. create new worksheet in workbook , fill first row names (pos
, art no
...).
2. put formula in a2
.
=index(input!$b$1:$b$9,(row()-1)*3-3+column(),1)
- copy cell , paste in final array.
not explain: takes 1st, 2nd , 3rd of every 3 values in values column using row position. modify length of input array 9 needs. if sequence of input not constant can accomplished it's little longer.
Comments
Post a Comment