• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 660
  • Last Modified:

Delete blank pagraphs in between tables using search and replace functionality

Dear Experts:

How can I delete blank paragraphs in between tables using the search and replace functionality.

The search for ^p and replace it with nothing approach does not seem to work.

I have attached a sample file for your convenience.

The result of this 'search and replace operation' or a VBA code should be that there is just one table left.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
Andreas Hermle
Andreas Hermle
1 Solution
Hi Andreas,

It seems that the Find and Replace has been designed not to delete paragraphs in the case that they are keeping tables separated.
You can do it with a macro:
Sub JoinTables()
    Dim rng As Range
     Set rng = ActiveDocument.Range
     With rng.Find
        .Text = "^p"
        Do While .Execute
            If ActiveDocument.Range.End - rng.End < 2 Then
                Exit Do
            End If
    End With
End Sub

Open in new window

Andreas HermleTeam leaderAuthor Commented:
Hi Graham,

wow, great coding, Graham! Thank you very much for your professional help.

Regards, Andreas
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now