Solved

Macro to format table cells

Posted on 2006-11-14
2
369 Views
Last Modified: 2008-02-01
Hi there,
I need a macro that will scan down through a document, looking for any tables in it. When it finds a table it will scan the cells and if it finds any blank ones it will insert the text "N/A" (without the quotes). It then moves onto the next table (if there is one) does the same and continues on until it reaches the end of the document.

Many thanks in advance

Michael
0
Comment
Question by:daleoran
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 125 total points
ID: 17937515
Hi Mike.

Try this one:

Sub DefaultCellData()
    Dim tbl As Table
    Dim cl As Cell
   
    For Each tbl In ActiveDocument.Tables
        For Each cl In tbl.Range.Cells
            If Len(cl.Range.Text) < 3 Then 'cell range returns visible text + 2 format characters
                cl.Range.Text = "N/A"
            End If
        Next cl
    Next tbl
End Sub
0
 
LVL 10

Author Comment

by:daleoran
ID: 17937704
Brilliant - Many thanks :)

Michael
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Like many others, we try and discourage users from printing documents unnecessarily and instead send or share them electronically. However, this doesn't always work and documents are still printed. With this simple solution, if the user tries to …
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now