Word

Mark all empty cells in table

Ease of Use

Easy

Version tested with

2000, 2002, 2003 

Submitted by:

MOS MASTER

Description:

If the selection is within a table then the sub will mark all empty cells in table. 

Discussion:

You want a visual way to determine all empty cells are trully empty (No non-printing characters in them) The used method for checking the end of cell marker can come in use if one wants to test for a empty cell before filling it. 

Code:

instructions for use

			

Option Explicit Sub MarkEmptyCells() Dim oCell As Word.Cell With Selection ' \\ Check if selection is in a table If .Information(wdWithInTable) Then ' \\ Loop Through all cells in table For Each oCell In .Tables(1).Range.Cells ' \\ Check if the cell only has a ' \\ end of cell marker (Chr(13) and Chr(7)) If oCell.Range.Text = Chr(13) & Chr(7) Then ' \\ Cell is empty give it texture oCell.Shading.Texture = wdTextureSolid End If Next End If End With End Sub

How to use:

  1. Open your Word document.
  2. Press Alt + F11 to open VBE.
  3. Insert-Module. (Insert -> module)
  4. Paste the code there in the window at right. (F7)
  5. Close VBE (Alt + Q or press the X in the top right hand corner).
  6. Save the file.
 

Test the code:

  1. Put the cursor in a table
  2. From Word, press Alt + F8 to open the macro dialog box.
  3. Select MarkEmptyCells
  4. Click Run.
 

Sample File:

Mark Empty Cells.zip 7.49KB 

Approved by mdmackillop


This entry has been viewed 112 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express