In today’s post, we will provide you with 4 effective methods to exclude header rows while sorting the contents of a Word table.
In Word, we prefer to use table to hold all kinds of data. Most of time, we are dealing with numbers. Then inevitably, sorting data will be one of our daily tasks. However, when doing this, you must aware that if your table contains one or more header rows. If it does, you need to pay a bit more attention.
Here are 4 ways to sort in a table.
Method 1: Sort the Contents of a Table with One Header Row
- If your table contains just one header row, then put cursor inside it.
- Then click “Layout” tab.
- Next click “Sort” in “Data” group to open the same name dialog box.
- In “Sort” box, select the “Header row” at the left-down corner.
- Then select a sorting rule, be it ascending or descending.
- Finally, click “OK”.
Now, if your table contains 2 or more header rows, you will need the following methods, because Word recognizes only one header row.
Method 2: Specify Header Rows
- First of all, select rows that you want to set as header rows.
- Next, click “Layout” tab, too.
- And click on the “Repeat Header Rows”.
- Then deselect the rows, but make sure the cursor is in the table whose contents are to be sorted.
- Next click “Sort” and specify a sorting rule.
- Click “OK” at last.
Method 3: Select Rows to Be Sorted
- This time select rows that contain contents to be sorted.
- Then click “Sort” command.
- In “Sort” box, click on the combo box of “Sort by” and choose a column.
- And you can also set a column to sort in the “Then by” combo box.
- Next choose a sorting rule and click “OK”.
You may notice that you can choose a column to be sort in method 3. But you are unable to do so with the proceeding 2. So, here is the macro way, which not only allows you to specify the start of a sorting range but also a specific column to sort by.
Method 4: Run Word Macro
- To begin with, place cursor inside a table and press “Alt+ F11” to open VBA editor.
- Then click Normal” on the left column.
- And click “Insert” on menu bar.
- Select “Module” on that drop-down menu.
- Open it by double click.
- On the module, paste following codes:
Sub SortCurrentTable() Dim strRowNum As String Dim strSortRule As String Dim strField As String Application.ScreenUpdating = False strRowNum = InputBox("Enter the row number of the row which you want to start sort:", "Row Number") strSortRule = InputBox("Enter one of the following values:" & vbNewLine _ & "0 for ascending" & vbNewLine & "1 for descending", "Sorting Rule") strField = InputBox("Enter the number of field by which you want to sort:", "Field Number") With Selection.Tables(1).Range .Start = .Rows(Int(strRowNum)).Range.Start .Sort SortOrder:=Int(strSortRule), FieldNumber:=Int(strField) End With Application.ScreenUpdating = True End Sub
- Next click “Run” button to execute codes.
- Then in the first input box prompting up, enter a row number.
- Click “OK” to proceed.
- And in the “Sorting Rule” box, enter a value representing sorting rule and click “OK”.
- Next in “Field Number” box, enter a column number and click “OK”.
Address Document Issues
In use of Word, we are easily to encounter with different kinds of errors. Some can be fixed with a simple restart. Others, however, are more dreadful. This is extremely true when you inherit a damaged doc.Then you best shot is to get a tool to repair it.
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including damaged Excel and pdf repair software products. For more information visit www.datanumen.com