vba - Convert multiple rows to columns in Excel -
i have sheet containing clients , dependents. listed
ssn last name first name relationship
000-00-0000 smith john client
000-00-0000 smith freddy son
000-00-0000 smith beth daughter
111-11-1111 johnson alan client
111-11-1111 johnson carla spouse
i need listed clients row, , dependents listed beside (next columns), this:
ssn last name first name dep1 fn dep1 rel dep2 fn dep2 rel
000-00-0000 smith john freddy son beth daughter
111-11-1111 johnson alan carla spouse
ssn determining factor on this, since last names different. have seen vba questions have had similar answers, can't seem find modify specifically.
edit:
the code have tried is:
sub tgr() dim wsinput worksheet dim wsoutput worksheet dim acell range dim arrresults() variant dim resultindex long dim scurrent string dim sline string set wsinput = activeworkbook.sheets("input") set wsoutput = activeworkbook.sheets("output") wsinput.range("a1").currentregion .sort .resize(, 1), xlascending, .offset(, 1).resize(, 1), , xlascending, header:=xlguess redim arrresults(1 .cells.count, 1 1) each acell in .resize(, 1).cells if acell.value & "|" & acell.offset(, 1).value <> scurrent scurrent = acell.value & "|" & acell.offset(, 1).value resultindex = resultindex + 1 arrresults(resultindex, 1) = scurrent end if arrresults(resultindex, 1) = arrresults(resultindex, 1) & "|" & acell.offset(, 2).value next acell end wsoutput.range("a1").resize(resultindex) .parent.usedrange.clear .value = arrresults .texttocolumns .cells, xldelimited, other:=true, otherchar:="|" end end sub
i found on different question, listing out things how need them, except last names of dependents beside client. no relationship or first name or anything. know nothing vba, i'm not sure parts of code change.
any appreciated!
edit 2:
report comes our database:
how need report look:
Comments
Post a Comment