Remove blank rows in table

前端 未结 7 1639
心在旅途
心在旅途 2020-12-18 23:57

I\'m trying to run a macro that selects blank cells in a table column and deletes the entire row.

The script below does everything except the deleting part, which p

7条回答
  •  温柔的废话
    2020-12-19 00:28

    Two notes regarding Frej Lindstrom's solution, which I used but had to tweak a little:

    (1) add an End If before the Next

    (2) add "i = i - 1" just before the End If

    Why? because if you have blank rows one above each other, you'll skip one since all the rows' numbers just shifted one up. Essentially, if you deleted row [N], another row is now row [N], and you need to also test it rather than moving immediately to row [N + 1].

    BIG CAVEAT: if your last row is blank, this will give you a stuck loop. I'll probably put in an IF to handle it, though.

    I know this is an old thread, but thought I'd add this in case anyone else comes through looking for similar solutions. Thank you to Frej - your code really helped!

提交回复
热议问题