Ads

Custom logo design for just $99 USD!

Thursday, February 10, 2011

Find all empty Cells in a Table

If you are working with a table and want to find which cells are empty, then it is not easy. You can find a text  using find dialog box in MS Word, but it will not work for searching an empty cell.

An epmty cell in a table does not contains zero length text. Actually every cell of a table contains a 'start character' at the begining of the cell, and an 'end character' at the end. An empty cell contains only start and end characters having nothing between them. So the length of an empty cell in not zero. It is two charakter long.

Here is a VBA macro that will highlight all empty cell of a table within your selection. Just select a part (or full) of a table and run this macro. All empty cells within the selection will be colored blue.

Just copy the code and paste in MS word macro window.
-----------------------------
Sub MarkEmptycell()

    Dim C As Cell
    For Each C In Selection.Cells
    C.Select
    If Len(Trim(Selection.Text)) = 2 Then
    C.Shading.ForegroundPatternColor = wdColorBlue
    End If
    Next C
    Selection.Collapse
   
End Sub
----------------------------

If you are facing any problem with MS Office, just send a mail to jupiter_joyprakash@yahoo.co.in