Solved

Macro to format table cells

Posted on 2006-11-14
2
375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
Suggested Courses

738 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