Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 06-08-2018, 08:40 AM
d4okeefe d4okeefe is offline Can I clear the contents of a table using VBA Windows 10 Can I clear the contents of a table using VBA Office 2016
Advanced Beginner
 
Join Date: Apr 2013
Posts: 77
d4okeefe is on a distinguished road
Default

To clear contents of the tables, I think you have to use a for loop, accessing each cell. Something like this:
Code:
    Dim t As Table
    Set t = ActiveDocument.Tables(1)
    Dim i As Integer, j As Integer
    For i = 1 To t.Rows.count
        For j = 1 To t.Columns.count
            t.Cell(i, j).Range.Text = ""
        Next j
    Next i
You may not need this though. You could just use a template, or a dotx file. The original would always have a cleared table. However, the user-filled doc would need to be saved somewhere.
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I clear the contents of a table using VBA Table of contents JasonMichelM Mail Merge 4 09-15-2017 06:31 PM
Creating a Table of Contents in a table format Ellymoo Word 9 06-22-2017 08:15 AM
Table of contents with section breaks (text in table in header) Dmonk Word 2 05-23-2017 04:29 AM
Can I clear the contents of a table using VBA Move table cell contents from one table to another table or cell in same table donaldadams1951 Word VBA 4 02-04-2015 03:54 PM
Can I clear the contents of a table using VBA Table with Table of Contents as a Column dynamictiger Word Tables 4 07-21-2014 10:16 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft