It's not entirely clear what you're trying to do. If you just want to delete the headings, then you can do this without a macro:
- Press Ctrl + Alt + Shift + S to show the Styles pane
- Hover over the Heading 5 style, then click the down-facing arrow that appears on the right side
- Select Select all # instance(s) (for large docs, sometimes the number of instances won't be displayed)
- Press the Delete key
Or are you trying to delete just the text that follows a Heading 5 heading? Both the heading AND the text? If also text, how much text? Until the next lower-numbered heading?