I have an Excel file with a cell that includes the key to the record and another cell that has text for the key; the information is coming from a SQL Server database.
The text cell includes line feeds and blank rows, and I need to split the contents of this cell into as many 70-character rows as needed. For each row I need to use the same key value, as well as a 'line sequence' number. Regarding the text, I need to keep whole words, and respect the white lines and line breaks found in the original cell.
Below is an example of one of the cells (A1 is the key cell, and A2 is the text cell):
A1
ANUAL-LCD-FIX#0
A2
1-Limpieza general.
2-Revision de tornilleria en todo el equipo, reapretar de ser necesario.
3-Revision de pines, que no esten danados, reemplazar de ser necesario, (revisar con ingenieria).
4-Revision de la pantalla, que este funcional y que no este golpeada.
After splitting, this is what I need to get; please note that 3 columns (A, B and C) and 6 rows (1..6) would need to be created:
A1
ANUAL-LCD-FIX#0
B1
01
C1
1-Limpieza general.
A2
ANUAL-LCD-FIX#0
B2
02
C2
2-Revision de tornilleria en todo el equipo, reapretar de ser
A3
ANUAL-LCD-FIX#0
B3
03
C3
necesario.
A4
ANUAL-LCD-FIX#0
B4
04
C4
3-Revision de pines, que no esten danados, reemplazar de ser
A5
ANUAL-LCD-FIX#0
B5
05
C5
necesario, (revisar con ingenieria).
A6
ANUAL-LCD-FIX#0
B6
06
C6
4-Revision de la pantalla, que este funcional y que no este golpeada.
I have found some examples online that split cells, but the length of the cell being split is pre-determined, and they do not have white lines or line breaks; in my case, some of those cells are less than 70 characters, while others are much longer, so it is hard to know in advance how many rows will be needed to split each text cell.
Could anyone suggest me how to accomplish this? Let me know if more info or details are needed.
Thanks.
Try this code:
It assumes that the original list is placed with headers in cell A1 of a sheet named Sheet1 and is like the sample you have given. If that's not the case, edit the code accordingly. For example: you can edit the line
Set RngKeyList = Sheets("Sheet1").Range("A2")
to target the first cell of the Key column that contains data.