vba - Finding and Outputing multiple entries in an excel array -
i have more complicated spreasheet explain trying simpler spreadsheet.
have 2 columns, first column has first names , second column has last names.
for example:
column1 michael; michael; michael; george; michael; henry; column 2 keaton; douglas; jackson; washington; jordan; ford;
i create either excel formula or vba function search column 1 rows match "michael" , return last names associated "michael" first names. preferably, concatenating last names space in between. vlookup, index, match, , array functions in excel won't work because return first "michael" last name. have tested vba function below , seems work feedback on function or suggestions on formula work.
so output of function above columns be:
" (keaton) (douglas) (jackson) (jordan)"
any or suggestions welcome.
vba code.
sourcearray first names, id "michael", targetarray last names.
public function drawid(arrinput variant, id string, arroutput variant) dim arraysize integer dim integer arraysize = application.worksheetfunction.counta(arrinput) = 1 while <= arraysize if arrinput(i) = id drawid = drawid & " (" & arroutput(i) & ")" end if = + 1 loop end function
seams need pivot table. give try.
to firstname lastname
, suggest add third column concatenation (eg: c1=a1&" "&b1
)
Comments
Post a Comment