Thursday, 15 May 2014

excel - Concatenate by selecting cells in multiple columns -



excel - Concatenate by selecting cells in multiple columns -

i have column each of 4 variables, lets phone call them a,b,c,d. each variable has multitude of values. want select 1 cell in each column , press button would: 1)concatenate them , 2) place result in column e. select a2, b5,c3 , d1, press magic button (maybe magic button needs pressed before , after selecting cells) , in column e have concatenation of values in: a2, b5, c3, d1 placed in column e. in advance.

i'd define custom concatenation function in vba, e.g.

function conc(v variant, optional byval sdelim string = "") string dim vloop variant if isarray(v) or typename(v) = "range" each vloop in v if conc = "" conc = vloop else conc = conc & sdelim & vloop end if next vloop else conc = cstr(v) end if end function

and can utilize in sub liking, e.g.

sub concatenatecells() range("e1") = conc(selection) end sub

i'm saying liking since didn't explain in column e should result gary's pupil pointed out. can bind sub button or shortcut ctrl+shift+c.

excel concatenation

No comments:

Post a Comment