To delete a range in Word VBA, use the Delete method on a Range object. The shortest working pattern is ActiveDocument.Range(Start:=0, End:=10).Delete to remove the first ten characters, or Selection.Range.Delete to remove whatever is currently selected. The method removes the text, and any tables or inline objects fully inside the range, but it does not remove paragraph marks that sit just outside the range boundaries unless you include them in the start and end positions. This guide covers the exact syntax, how to target the right text, common errors, and how to recover when the wrong content disappears.
What You'll Need
- Microsoft Word on Windows or Mac with the Developer tab enabled (File > Options > Customize Ribbon > check Developer, or Word > Preferences > Ribbon & Toolbar on Mac).
- A document you can safely test on — work on a copy, because
Deleteis immediate and not covered by Undo once the macro finishes. - Basic familiarity with opening the VBA editor (Alt+F11 on Windows, Option+F11 on Mac) and inserting a module (Insert > Module).
Step-by-Step
- Open the VBA editor. Press Alt+F11 (Windows) or Option+F11 (Mac). In the Project pane, right-click your document or Normal and choose Insert > Module. Menu labels can differ slightly by Word version and region, but the Insert > Module path has been stable for years.
- Decide what the range should cover. A
Rangeis defined by a start and end character position, counted from the beginning of the document. Position 0 is before the first character. You can build a range explicitly withActiveDocument.Range(Start:=0, End:=50), or capture one from a search, a bookmark, or the current selection. - Write the minimal delete statement. For a fixed range:
For the current selection:Sub DeleteFixedRange() Dim rng As Range Set rng = ActiveDocument.Range(Start:=0, End:=50) rng.Delete End Sub
Run with F5. The text inside the range is removed and the remaining content closes up.Sub DeleteSelection() Selection.Range.Delete End Sub - Include or exclude the paragraph mark deliberately. If you want to remove the paragraph break after the text, extend the end position by one character (
End:=51) or userng.Delete Unit:=wdCharacter. If you want to keep the paragraph structure, stop the range before the paragraph mark. Deleting a range that ends exactly on a paragraph mark merges the following paragraph into the current one. - Delete by bookmark or found text. If the content is bookmarked,
ActiveDocument.Bookmarks("MyBookmark").Range.Deleteis safer than counting characters. For found text, useWith Selection.Find ... .Executeand thenSelection.Range.Deleteafter a successful match. - Handle tables and inline shapes. A range that fully contains a table deletes the table. A range that only partly covers a table deletes the covered cells' content but leaves the table structure. Inline pictures inside the range are removed; floating shapes anchored in the range are not, because they are not part of the text stream.
- Test on a copy and check the result. Run the macro, inspect the document, and use Ctrl+Z immediately if anything is wrong. Undo works for a single macro run in most cases, but not reliably after multiple operations in one procedure, so keep test runs small.
Common Mistakes
- Using
Range.Deleteon an unset object. DeclaringDim rng As RangewithoutSet rng = ...raises run-time error 91. Always assign the range first. - Confusing character positions with visible characters. Field codes, hidden text, and bookmarks occupy positions. A range that looks like ten characters may cover more or fewer visible characters than expected.
- Forgetting that
Deletereturns nothing. You cannot chain it like a function. Writerng.Deleteon its own line. - Deleting the whole document by accident.
ActiveDocument.Range.Deletewith no start and end removes all content. If you intended a section, set the range boundaries explicitly. - Assuming floating objects go with the text. Floating shapes and text boxes anchored in the deleted range usually remain. Delete them separately via the
Shapescollection if needed.
Tips
- Use
rng.Textin the Immediate window (Ctrl+G) to preview what a range contains before deleting it. - Prefer bookmarks or content controls over fixed character positions; they survive edits elsewhere in the document.
- Wrap destructive macros with
Application.ScreenUpdating = Falseand restore it toTrueat the end to speed up large deletions. - For repeated deletions, loop backwards through ranges so earlier positions are not shifted by later deletions.
- Keep a backup copy of any template before running a delete macro on it, because Undo history is cleared when the document closes.
Troubleshooting
Run-time error 91 (Object variable not set): the range was never assigned. Add the Set line and confirm the bookmark or search actually matched before deleting.
Run-time error 5941 (requested member of the collection does not exist): usually a bookmark name typo. Check the name in Insert > Bookmark and match it exactly, including case.
Nothing appears to happen: the range may be empty (start equals end) or point to a collapsed selection. Print rng.Start and rng.End to the Immediate window to verify.
Wrong text disappeared: press Ctrl+Z at once. If Undo is unavailable, close without saving and reopen the backup. Then rebuild the range using a bookmark or a Find match rather than raw character counts.
Table structure left behind: the range only covered part of the table. Extend the range to include the whole table, or delete the table object directly with ActiveDocument.Tables(1).Delete.
Macro runs but Word hangs: a loop may be deleting a range that never shrinks. Add a counter and exit after a set number of iterations while testing.
Frequently Asked Questions
Does Range.Delete remove formatting as well as text?
It removes the text and the characters' formatting because the characters themselves are gone. Surrounding paragraphs keep their own formatting, but a paragraph mark deleted at the boundary can merge two paragraphs and adopt the first one's style.
Can I delete a range without affecting the clipboard?
Yes. Range.Delete does not use the clipboard, unlike Selection.Cut. The deleted content is not recoverable from the clipboard afterwards.
How do I delete only the text and keep the paragraph mark?
Set the range end one character before the paragraph mark, or use rng.MoveEnd Unit:=wdCharacter, Count:=-1 before calling Delete.
Why does my range delete more than I selected?
Character positions include hidden text, field codes, and bookmarks. Turn on formatting marks (Ctrl+Shift+8) and inspect the range's Start and End values to see what is actually covered.
Is Range.Delete the same as Selection.Delete?
Effectively yes for the covered content, but Selection.Delete acts on whatever is currently selected and depends on the cursor position, while a Range object is independent of the selection and safer in automated routines.
Can I undo a macro that used Range.Delete?
Usually a single Ctrl+Z reverses the last macro action, but multiple deletions inside one procedure may collapse into one undo step or become unrecoverable. Always test on a copy.