Hi Graham,
Thanks for that but I am still throwing an error. It would be helpful if it told me what the error was, but it just throws a dialog box with a red X in it, so who knows?
Anyway, it seems that it doesn't like it when cells are vertically merged to the left and not vertically merged to the right. i have some rows where the first cell of 2 rows is merged an the rest of the cells are not. Apparently doesn't care for this at all.
Another solution would be to simply split the table and evaluate only the target table then recombine them. I was trying to void that, but may not be able to.
Main Topics
Browse All Topics





by: GrahamSkanPosted on 2009-09-28 at 00:54:13ID: 25437386
I have tried with a table where the cells from the first and second columns are merged in one of the rows, and I don't get an error. What error do you get, and on which line?
If the cells were vertically merged, e.g. by combining the first-column cells in adjacent rows, then I would expect an error (no 5991 - Cannot access individual rows in this collection because the table has vertically merged cells.) on the For Each line.
However merging is done you can step through each cell in a table and examine the RowIndex and ColumnIndex properties. However, it isn't always easy to deduce from that whether the cell has been merged horizontally or vertically, but the attached 'DelRowsByCell' code also works in my tests.
You could step through the rows collection by index:
For r = 4 to tbl.Rows.Count
rw = tbl.Rows(r)
Or you could still use the For Each, but check the RowIndex of the first cell as in the DellRowsAfter sub below.
Select allOpen in new window