excel - Merging Rows with common column -
how can merge rows same date together? merge/centre function doesn't work. removing duplicates doesn't work either. thanks.

try code consolidate rows matching date:
sub consolidaterows() 'takes rows , consolidate 1 or many cells, based on 1 or many cells matching above or below rows. dim lastrow long, long, j long dim colmatch variant, colconcat variant '**********parameters update**************** const strmatch string = "a" 'columns need match consolidation, separated commas const strconcat string = "b,c,d" 'columns need consolidating, separated commas const strsep string = "" 'string separate consolidated values '*************end parameters******************* application.screenupdating = false 'disable screenupdating avoid screen flashes colmatch = split(strmatch, ",") colconcat = split(strconcat, ",") lastrow = range("a" & rows.count).end(xlup).row 'get last row = lastrow 2 step -1 'loop last row 1 j = 0 ubound(colmatch) if cells(i, colmatch(j)) <> cells(i - 1, colmatch(j)) goto nxti next j = 0 ubound(colconcat) cells(i - 1, colconcat(j)) = cells(i - 1, colconcat(j)) & strsep & cells(i, colconcat(j)) next rows(i).delete nxti: next application.screenupdating = true 'reenable screenupdating end sub
Comments
Post a Comment