excel - How do I merge a random number of cells with a blank cell in a column? -
example of dataset:
blank 1 2 blank 3 4 5 blank 6 i want merge cells below blank cell blank cell, stop counting when reaches next blank cell.
end result should this, strings concatenated
12 345 6 i'm trying create array 1s , 2s 2 meaning blank cell, counting 1s , merging them. don't know if work or if there easier way this.
this requires select area want merge, starting first blank cell , ending last cell value. delete entire rows; not sure if that's wanted:
sub mergeconstantsintoempties() dim blankcells excel.range dim constantcells excel.range dim long dim mungedcontents string selection set blankcells = .specialcells(xlcelltypeblanks) set constantcells = .specialcells(xlcelltypeconstants) end = 1 blankcells.areas.count if constantcells.areas(i).count = 1 mungedcontents = constantcells.areas(i).value else mungedcontents = join(application.worksheetfunction.transpose(constantcells.areas(i).value)) end if blankcells.areas(i).value = mungedcontents next constantcells.entirerow.delete end sub
Comments
Post a Comment