Hi.
I'm brand new to VBA, but have coded in VB before.
In Microsoft Word, starting with a table of 33 rows and 3 columns, I want to split each of the initial 33 rows (of column 3 only) into 10 rows each.
I thought this would be pretty easy, but the code (below) doesn't work. It actually works for the first 2 (of the original) rows, but then the count somehow gets messed up and the third original row doesn't work. I'm not sure why (the count will continue to increase as I am adding 10 rows at a time). As well, the routine ends with no error messages and the job is not complete (except for the first two original rows).
The code I'm using:
Any illumination would be helpful.Sub SplitColumnIntoRows() ' In Microsoft Word, split each of the initial 33 rows (of column 3 only) into 10 rows each. Dim tbl As Table Dim row As Integer Dim rowCount As Integer Dim col As Integer ' Set the table reference to my specific table Set tbl = ActiveDocument.Tables(1) ' Loop through the appropriate cell in the table (column 3 only) col = 3 rowCount = tbl.Columns(col).Cells.Count For row = 1 To rowCount Step 10 tbl.cell(row, col).Select ' Split cell into desired number of rows Selection.Cells.Split NumRows:=10, NumColumns:=1 rowCount = tbl.Columns(col).Cells.Count Next End Sub
Thank you in advance.