I
isabel.hay
Hi,
I'm creating a Word document using vba in Excel, and populating it with
data from the spreadsheets.
I have table with 5 columns.
In each row, I may need to split the cell in columns 4 & 5 several
times.
I split the cell in column 4 and populate the new cells as follows (the
'original' cell already has some text in it):
For Each varRole In arrRoles
intRoles = intRoles + 1
rngWord.Cells.Split 2, 1, False
rngWord.Move wdCell, 2 '2seems to be needed
to move 1 cell due to the post-split selection by excel
rngWord.Text = CStr(varRole)
Next
My problem is that I then want to move to the next cell in the row, in
column 5, then split and populate that. I've tried various ways of
moving ('rngWord.Move wdColumn, 1' and 'rngWord.Move wdCell, 1' (or 2),
but they don't seem to work from a split cell (so the splits for the
next column end up in this one) ('move wdcell, 1' works for a non-split
cell).
Prefixing the Move with 'rngWord.Collapse wdCollapseEnd' doesn't seem
to help either.
How do I move on to the next cell along, in the next column, please?
I'm creating a Word document using vba in Excel, and populating it with
data from the spreadsheets.
I have table with 5 columns.
In each row, I may need to split the cell in columns 4 & 5 several
times.
I split the cell in column 4 and populate the new cells as follows (the
'original' cell already has some text in it):
For Each varRole In arrRoles
intRoles = intRoles + 1
rngWord.Cells.Split 2, 1, False
rngWord.Move wdCell, 2 '2seems to be needed
to move 1 cell due to the post-split selection by excel
rngWord.Text = CStr(varRole)
Next
My problem is that I then want to move to the next cell in the row, in
column 5, then split and populate that. I've tried various ways of
moving ('rngWord.Move wdColumn, 1' and 'rngWord.Move wdCell, 1' (or 2),
but they don't seem to work from a split cell (so the splits for the
next column end up in this one) ('move wdcell, 1' works for a non-split
cell).
Prefixing the Move with 'rngWord.Collapse wdCollapseEnd' doesn't seem
to help either.
How do I move on to the next cell along, in the next column, please?