I am trying to split the cell content with length greater than 72 into separate rows with their length not increasing more than 72 chars. But I was trying to do how can I repeat the serial number for each cell while dividing them into 72 chars. For example if I have a cell with 144 chars and serial number S1 assigned to it in another column, so when I use the above module to divide the text into 2 cells then the same Serial number S1 is also copied to each new cell created. Can we do it? Code is as below;
Any suggestions?
Thanks
Now that you have provided examples of your input data and desired output, here is one way to accomplish that, modifying the storage routines in the previously provided code.
Since one cannot Redim Preserve an array changing the size of the first dimension, we use a Collection object to collect all the individual lines, and then size and populate the results array in a separate step.
Some assumptions are that the source data is on sheet1 columns A:C with column headers in row 1, and that the results will be written on sheet2.
Go through the code and understand what is going on at each step. Ask question to clarify as to why something is done one way vs another.
Before:
After:
One simple method would be to create a range that increments as the new cells are added, and then after all of the new cells have been created, run through the range and append the serial number as appropriate. So, assuming the serial number is in Cells(1,2) (though this can be easily adjusted), add this to the original processing loop.