I have a 100 rows of notes all listed across rows in one column. Each paragraph includes one or multiple rows, then there is a gap/empty row, then the next paragraph starts. I want the VBA to concatenate these rows accordingly to construct a paragraph, then moved to the next set of rows to continue doing the same. if its a one line/row, then it would only return that one line. The code below works for a paragraph up to 6 or 7 lines, not defective at all. some paragraphs include 10 to 15 rows. Please let me know if its not clear.
My logic starts with:
IF the cell to left IS NOT BLANK, and the cell above it (top left) IS BLANK (indicator of the beg)inning of a paragraph), IF the cell below it IS NOT BLANK, below left (indicates that there are at least two cells to be concatenated), CONCATENATE them if the following cell IS BLANK, otherwise keep checking until reach a blank cell then CONCATENATE all of the row/cells up to that line.
IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)=""),INDIRECT("RC[-1]",0),IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)<>"",INDIRECT("R[2]C[-1]",0)=""),CONCATENATE(C124," ",C125),IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)<>"",INDIRECT("R[2]C[-1]",0)<>"",INDIRECT("R[3]C[-1]",0)=""),CONCATENATE(C124," ",C125," ",C126),IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)<>"",INDIRECT("R[2]C[-1]",0)<>"",INDIRECT("R[3]C[-1]",0)<>"",INDIRECT("R[4]C[-1]",0)=""),CONCATENATE(C124," ",C125," ",C126," ",C127),IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)<>"",INDIRECT("R[2]C[-1]",0)<>"",INDIRECT("R[3]C[-1]",0)<>"",INDIRECT("R[4]C[-1]",0)<>"",INDIRECT("R[5]C[-1]",0)=""),CONCATENATE(C124," ",C125," ",C126," ",C127," ",C128),IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)<>"",INDIRECT("R[2]C[-1]",0)<>"",INDIRECT("R[3]C[-1]",0)<>"",INDIRECT("R[4]C[-1]",0)<>"",INDIRECT("R[5]C[-1]",0)<>"",INDIRECT("R[6]C[-1]",0)=""),CONCATENATE(C124," ",C125," ",C126," ",C127," ",C128," ",C129),""))))))
My logic starts with:
IF the cell to left IS NOT BLANK, and the cell above it (top left) IS BLANK (indicator of the beg)inning of a paragraph), IF the cell below it IS NOT BLANK, below left (indicates that there are at least two cells to be concatenated), CONCATENATE them if the following cell IS BLANK, otherwise keep checking until reach a blank cell then CONCATENATE all of the row/cells up to that line.
IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)=""),INDIRECT("RC[-1]",0),IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)<>"",INDIRECT("R[2]C[-1]",0)=""),CONCATENATE(C124," ",C125),IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)<>"",INDIRECT("R[2]C[-1]",0)<>"",INDIRECT("R[3]C[-1]",0)=""),CONCATENATE(C124," ",C125," ",C126),IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)<>"",INDIRECT("R[2]C[-1]",0)<>"",INDIRECT("R[3]C[-1]",0)<>"",INDIRECT("R[4]C[-1]",0)=""),CONCATENATE(C124," ",C125," ",C126," ",C127),IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)<>"",INDIRECT("R[2]C[-1]",0)<>"",INDIRECT("R[3]C[-1]",0)<>"",INDIRECT("R[4]C[-1]",0)<>"",INDIRECT("R[5]C[-1]",0)=""),CONCATENATE(C124," ",C125," ",C126," ",C127," ",C128),IF(AND(INDIRECT("RC[-1]",0)<>"",INDIRECT("R[-1]C[-1]",0)="",INDIRECT("R[1]C[-1]",0)<>"",INDIRECT("R[2]C[-1]",0)<>"",INDIRECT("R[3]C[-1]",0)<>"",INDIRECT("R[4]C[-1]",0)<>"",INDIRECT("R[5]C[-1]",0)<>"",INDIRECT("R[6]C[-1]",0)=""),CONCATENATE(C124," ",C125," ",C126," ",C127," ",C128," ",C129),""))))))