"Ads by Google" links provided by Google.com, which has sole control over all advertising content it displays on this site.

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

Barry MacDonnell's
Toolbox for WordPerfect

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

Page updated Oct 24, 2007
WordPerfect Tips
Main tips page | Browse tips

Using WordPerfect tables

WordPerfect tables offer more than the ability to organize information in columns and rows: They can do calculations, sort, etc.

Here are some "How To" tips and links to other information.
(This is not a comprehensive list, but a "work in progress." Additional tips are welcome.)

Numbering rows in a table

Wrapping text around a table

Force a table cell that could possibly evaluate to zero to display blank

Sorting WordPerfect tables

Sorting regular paragraphs in reverse order

"Bracketing" text outside the left margin with a large "[" bracket

  • Numbering rows in a table
    • Method A: Use QuickFill
      • Type a "1" in the first (top left) cell, then a "2" in the next cell down, in column A. Select the entire column (tip: move the cursor inside the column until it turns to an up arrow, then double-click your mouse), right-click the selected column, and choose QuickFill from the context menu that appears. All cells in that column will be populated with incrementing numbers.
    • Method B: Use a table formula
      • Postion the cursor in the first (top) cell of the column you want numbered, then click on Table>Formula Toolbar.
      • Click on Functions, then select All, and scroll down to Row(). Clck on Row(), then Insert. The formula will appear to the right of the blue arrow in the formula field. Click on the blue checkmark and the function will put the row number in the cell.
        • Alternative: Just type (without quotes) "+Row()" into the formula field, then click the blue checkmark.
      • Click on Copy Formula. Select Down, and enter the number of rows into which to copy the function. (Tip: To copy it to all rows in the column, click and hold the small up arrow to the right of the field; it will increment numbers until it reaches the maximum.)
    • Method C: Use a macro to populate all cells in the column
      • Here's a macro that can do the same thing as QuickFill, but can be played anytime -- especially after inserting or deleting rows, which can cause disruptions in numbering the rows.
      • Note that the table formula method will not suffer disruptions since +Row() always returns the current row number. Note also that the macro assumes you want to start numbering in cell A1; if not, delete the first PosTableBegin command.

        // QuickFill.wcm

        // Deletes any existing items in the first column, then adds incrementing numbers (1..n) in that column.

        If(NOT ?InTable)
        Quit
        Endif

        Messagebox(vAns; "Caution"; "The first column's contents will be deleted and replaced with incrementing numbers." ; OKCancel!)

        If(vAns=2)
        Quit
        Endif

        PosTableBegin
        SelectTableColumn
        SelectDelete
        Type("1")
        PosCellDown
        Type("2")
        SelectTableColumn
        TableDataFill
        SelectOff
        PosTableBegin

        Quit

      • A more robust version of the QuickFill macro can be found in the Library.
    • Method D: Use automatic paragraph outline numbers in the column's cells (see here)
  • Wrapping text around a table
    • The table should already have been created. In the Reveal Codes window, carefully select and copy (Ctrl+C) everything between (and including) the [Tbl Def] and [Tbl Off] codes to the Windows clipboard.
    • Open a new, empty document and paste the table into it for temporary safe-keeping. Return to the original document and delete the original table (including the [Tbl Def] and [Tbl Off] codes). Reformat any document text, if needed.
    • Create a graphics box on the page with Insert, Graphics, Custom Box, Table, OK. Double-click on the empty box to edit it (or right-click it, then choose Content, Edit). Paste the table (Ctrl+V) from the clipboard into the Editor window that appears, then exit back to the document with File, Close or by clicking the Close icon on the property bar. (Note that the box can be resized later; the table will resize automatically inside the box, unless you have fixed the sizes of columns.)
    • Select the box by right-clicking on it and choosing Select Box from the context menu. (Eight "drag handles" appear around the perimeter.) This will let you drag the box into a new position on the page. Or, you can use Position from the context menu to specify an exact location. (The box can be repositioned later, if needed.)
    • While still selected, right-click the box and Choose Position, Attach...; this lets you "anchor" the box in a specific location. (For small tables you probably want to anchor it to a specific paragraph so it will move with that paragraph.)
    • Right-click the box again. From the context menu you can wrap the text around the box in various ways, or re-size the box, reposition it, add a border, add a caption, etc. You should experiment with the various options to get the effect you want.
    • Exit from the box by clicking elsewhere on the page.
    • Related tips:
      • If you resize columns to a specific width, set the table to "Center" position on the "page" (right-click the table, use Format on the context menu, then look under the Table tab). "Full" overrides the column widths, but lets you automatically expand/contract the table width by adjusting the graphic box's dimensions.
      • This is a good technique to use if you need to rotate a table 90 degrees, since you can rotate the contents of the box by right-clicking it and choosing Content, Rotate.... This can be useful when mixing landscape pages with portrait pages.
  • Force a table cell that could possibly evaluate to zero to display blank (i.e., not show a "0"):
    • Assuming you are calculating figures in two columns (e.g., cell A1 times cell B1) and want the result to be shown in the third column (e.g., cell C1) only if it is not equal to zero. Then, in Cell C1 (here, we assume the result of A*B should be multiplied by .50) -
    • +IF((A1*B1)=0, "", (A1*B1)*.50)
    • (Note the use of two double quotes with no space between them.)
  • Sorting WordPerfect tables
    • It is a good idea to save the document before performing any sort on it. Make sure to enable "Allow Undo" in the Options button drop list.
    • The individual items in a sort are considered to be "records." WordPerfect lets you sort five kinds of records: lines, paragraphs, merge records, parallel columns, and the rows in a table. Each row of a table is divided by cells (Columns), lines (Rows), and words. Cells are numbered from left to right, starting with cell 1.
    • To define a custom Table sort: Place your cursor in the table, click Tools, Sort, New. Give the sort a name, then with the Table Row button enabled, define the "Sort by" rule (or key), which defines the order in which the sort will be conducted. You can define additional rules with the Add Key button.
    • Normally, lowercase sorts before uppercase. To reverse this, click the Options button and choose "Uppercase sorts before lowercase."
    • To sort by the last word, use "-1" (without quotes) in the Word field, "-2" for the next to last word, etc.
    • Note that WordPerfect codes ([Tab], [Hd Left Ind], etc.) are treated as field separators by the sort feature. Spaces, forward slashes (/) and hyphens separate words.
  • Sorting regular paragraphs in reverse order
    • If you are keeping a diary, journal, or other document where you enter new lines (or paragraphs) at the end of the document, but now want to reverse the order of the items so that the most recent are at the top:
      • Select all paragraphs in the document. Click Table, Create and set the Columns = 1 and Text Delimiters = Paragraphs. Click OK. You should now have a table with all document paragraphs in separate cells.
      • With the cursor in the table, click Table, Insert, Columns = 1, Before, OK. You should now have a two-column table with the first column being empty.
      • Enter a 1 in the top cell of the first column, and a 2 in the cell just below it. Select just the entire first column, then click Table, QwickFill. This should sequentially number all cells in the first column. Click in the second column (or outside the table) to deselect the first column.
      • With the cursor in the table, click Tools, Sort to bring up the Sort dialog. Choose "First cell in a table row," then click New. Give the new sort routine a name (e.g., "Reverse table sort"). The "Sort by" radio buttons should be set to "Table row." Then, under "Keys," set the Type = Numeric and Sort Order = Descending. Click OK. With the new routine name ("Reverse table sort") selected in the Sort dialog, click Sort. The entire table should immediately sort into reverse order.
      • Place the cursor in the first (numbered) column. Click Table, Delete, Columns, 1, OK. You should now have a one-column table again.
      • With the cursor in the table, click Table, Convert. Select the "Convert tables to text" button, and the "Separate text with paragraphs (hard returns)." Click OK.
  • "Bracketing" text outside the left margin with a large "[" bracket
    • Here's the effect. Note that the text lines up with the left margin, and the bracket is "outdented."
    • Here's how to do it and create a QuickWord from it to make it easy to re-create anytime:
      • Open a new blank document. Create a 1-row, 2-column table with Table, Create.
      • Drag the middle vertical cell border to the left as far as it will go. This leaves a minimum-width left-hand column (you can resize this column to a specific dimension by right-clicking in the column, then choosing Format, Column). Typically, this is 0.67" wide. The right-hand column (the cell) will extend to the right margin.
      • Right-click in the right-hand column and choose Borders/Fill, and then click the Cell tab. Remove ("X") all 4 borders from that cell. This should leave the first cell (i.e., the left-hand column) with a 3-sided border shaped like a left bracket ("[").
      • Right-click in the right-hand column and set the top/bottom row margins with Format, Row (e.g., to 0.40" for each). Be sure to enable (check) "Divide row across pages" and click on the "Multiple lines" option. Set the inside left/right column margins to 0.0" with Format, Column; while there, align the contents in cells, if desired.
      • Exit from the table. Place the cursor just before (i.e., just to the left of) the [Tbl On] code. Change the left margin to 0.933" with Format, Margins. (This assumes your default left margin is 1.0". If not, set the margin appropriately so that the left margin dimension plus the width of the table's left column equal your normal left margin setting.)
      • Place the cursor just after the [Tbl Off] code and change the left margin back to 1.0" (or your preferred left margin setting).
      • The table should now be outdented beyond the left margin by the width of the first column.
      • To automate creating the table in future sessions -- turn it into a QuickWord:
        • Before adding any text to the table do this:
        • In Reveal Codes, place the insertion cursor before (just to the left of) the [Tbl Def] code.
        •  
        • In Reveal Codes, select the six adjacent codes (first remove any stray hard returns between them). These are the codes to select:
          [Lft Mar][Tbl Def][Row][Cell][Tbl Off][Lft Mar]
        • With the codes selected, create a QuickWord with Tools, QuickWords. Perhaps give it the name of "\[" (without quote marks).
        • Back in your document, type (without quotes) "\[".
        • Result: A new table with the "[" border outdented by the same amount as the first (empty) cell in the table.
      • Enter text in the second column of the table. The bracket will extend downward as you do this -- including onto the following page if necessary.