Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate

Barry MacDonnell's
Toolbox for WordPerfect

Macros, tips, and templates for Corel® WordPerfect® for Windows®
© Copyright 1996-2021 by Barry MacDonnell. All Rights Reserved.

Page updated Jan 22, 2015

DELETERC - Deletes empty rows and (optionally) columns from a table

Download DELETERC.ZIP (v2.0; 11/08/12; 17,354 bytes)

Written and tested in WPX6 but should be compatible with WordPerfect 8 and later versions

WordPerfect 11 users: See important information about using macros in the first release of WP11 ( at the top of this page.

Downloading, Documentation, Modifications, and Support


Related items -

RowLines - Adds underlines and/or fills (shading) to every Nth row in a table for added readability or improved appearance

Using WordPerfect tables (some tips) 


The DeleteRC.wcm macro ("Delete empty Rows and/or Columns") in the download ZIP archive (see left sidebar) can - 
  • delete all empty rows in the current table -- i.e., those rows without any visible (keyboard) characters in any cell in the row.


  • delete all rows that have empty cells in Column 1 -- even if they might have visible characters in other cells in the row. 


  • delete just empty columns -- which retains any empty (or partially empty) rows.

    Optionally, it can delete all empty columns (choice #3) immediately following the processing of all table rows (i.e., after choosing either #1 or #2 above).

    Optionally, it can retain the first column even if its cells are empty. (Some users might want the column available as a "check off" column.)

Menu screen shot.

Notes and tips

¤  Some items are ignored: Cells with just regular spaces (spacebar), format codes (bold, italics, styles, outline numbers, etc.), and images ([Box] codes) are not considered "text" during processing. Therefore, cells that contain only these items will be seen as empty during processing.

¤  WordPerfect symbols (Insert, Symbol... or Ctrl+w), on the other hand, will be seen as text and their cells will be considered filled.

¤  Menu defaults can be set in the redlined User Modification Area at the top of the macro code.

☼  If you need to select everything in a cell -- codes as well as text or other material -- so that you can delete all items, see Footnote 1.

Caution: Always make a backup of your document before playing this (or any) macro, or play it on a copy of your document. While you might be able to use Edit, Undo (or Ctrl+z) to restore all changes to the table (depending on your Undo options), it is always a good idea to have a backup just in case. [Disclaimer]

Related macro:

A macro posted by Roy "lemoto" Lewis on WordPerfect Universe removes any row which does not contain a specified string of characters (here, for example, the string is "DAB"). Perhaps the code will be useful to use as a starting point for similar tasks.

BE SURE to also indicate the specific table and cell in your own document in the PosTableCell() command below, which is set (for this example) for Table C, Cell C1.

To copy this code into your WordPerfect, see here.

vCheckText = "DAB"

PosTableCell("Table C.C1")
While(NOT ?TableLastCell)
PosTableCellDown ()

If(StrPos(?SelectedText; vCheckText) =0)

(Somewhat) related macro:

See SwapRecs, which can help you properly merge/print 2-column cards from a table containing merge data. The macro swaps every other record in a data text file or data table file. This produces a data file that will properly merge/print the reverse side of 2-column cards (e.g., "4-up" postcards or "10-up" business cards) with custom information (e.g., a person's name) on both sides.

Footnote 1

(Probably of interest mainly to macro writers:)

If you want to select the entire contents of a particular cell -- including all format codes, even those left behind be other operations -- here's a Procedure that should do the job.

Most of the code came from the DeleteRC macro; the blue lines were added to capture any format codes at the top of the cell.

// NOTE: Reveal Codes must be ON.

// Select the current cell's contents:
pSelectTableCellContents ()
// ... do other stuff here, such as delete the contents with SelectDelete ...

// Place this segment at the end of the macro:

Procedure pSelectTableCellContents ()
// Selects the entire contents of the current table cell:
If(NOT ?TableInTable) // Test cursor position
    Messagebox(;"Error in macro Procedure";"Not in a table cell")
PosTableCellTop  // Go before any items in cell -
While(?LeftCode>0 and ?LeftCode<>{195;196;197;198})
    PosCharPrevious // (moves before any codes except [Row], [Cell] etc.)
SelectMode(On!) // Turn select mode on -
PosTableCellBottom // Go to the bottom of the cell -
PosLineEnd // Go to the end of any line of text