Deleting empty rows in Word with VBA

Hello,

I am using a UserForm to delete some rows in a table (rows are a bookmark). But unfortunately, it only deletes the content but not the empty cells.

I tried having the entire table a bookmark also and wanted a code to search that entire table / bookmark for empty rows and delete them, after the first bookmark has been deleted.

But that would still be a bookmark in a bookmark.

What code can I use to ensure that all (completely!) empty rows are deleted in the document?


Thank you :)

Answer
Answer

Hey,

I found the solution, it was actually rather easy :)

If UserForm1.ComboBox1 <> "xxx" Then: ActiveDocument.Bookmarks("xxx").Range.Cells.Delete

The ".Cells" deleted the content together with the empty cells! Before I just had .Range.Delete, which only deleted the content, but not also the empty cells.

But thanks for your help!!!!

Mel

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated January 22, 2024 Views 2,651 Applies to: