excel - Concatenate certain cells from column based on two conditions -
i have excel worksheet of different football teams , squads, , information individual players. trying is, table, concatenate cells , place data cell on more simpler table other users see, instance, show players injured in teams. i'll explain:
f_team | player | injured liverpool coutinho 0 liverpool benteke 1 liverpool sturridge 1 man u rooney 1 chelsea sterling 0
so in other table looks this
f_team | players injured liverpool benteke, sturridge man u rooney
so data can grouped individual teams, stuck trying concatenate properly.
i have tried using vba, comes #name?
, don't know why, , don't know if doing correct.
function concatenateif(criteriarange range, criteriarange2 range, _ condition variant, condition2 variant, concatenaterange range, _ optional separator string = ",") variant 'update 20150414 dim xresult string on error resume next if criteriarange.count <> concatenaterange.count concatenateif = cverr(xlerrref) exit function end if = 1 criteriarange.count if criteriarange.cells(i).value = condition , criteriarange2 = condition2 xresult = xresult & separator & concatenaterange.cells(i).value end if next if xresult <> "" xresult = vba.mid(xresult, vba.len(separator) + 1) end if concatenateif = xresult exit function end function
and formula using:
=concatenateif($d$2:$d$20000, $l$2:$l$20000, z2, 1, $e$2:$e$20000)
column d f_team column e player column l injured column z f_team match against column d
if criteriarange.cells(i).value = condition , criteriarange2 = condition2 then
should be:
if criteriarange.cells(i).value = condition , criteriarange2.cells(i).value = condition2
p.s: in test, original code did not #name, full list of players. because of on error resume next
statement. highly recomment omit statement: since udf, if user types wrongly, let excel handle error own way (display #value), rather displaying whatever wrong data.
Comments
Post a Comment