Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-06-2013, 01:27 PM
So New2 This So New2 This is offline Delete table if cell has data Windows XP Delete table if cell has data Office 2007
Novice
Delete table if cell has data
 
Join Date: May 2013
Location: Cleveland,OH
Posts: 3
So New2 This is on a distinguished road
Default Delete table if cell has data

I've used this code to delete a table if a cell was empty, but now I need to do the opposite, that is delete the table if a cell contains data.
Code:
Public Sub SHUNT()
Dim oRng1 As Range
With ActiveDocument
  Set oRng1 = .Range(Start:=.Bookmarks("BK_SHUNTS").Range.End, End:=.Bookmarks("BK_SHUNTE").Range.Start)
  If Len(oRng1.Tables(1).Cell(1, 1).Range) = 2 Then
    oRng1.Tables(1).Delete
    GoTo finish
  Else
    Dim t1 As Table
    Set t1 = ActiveDocument.Bookmarks("BK_SHUNT").Range.Tables(1)
  End If
End With
finish:
End Sub
Thank you

Last edited by macropod; 05-06-2013 at 08:56 PM. Reason: Added code tags & formatting
Reply With Quote
  #2  
Old 05-06-2013, 09:00 PM
macropod's Avatar
macropod macropod is offline Delete table if cell has data Windows 7 64bit Delete table if cell has data Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,856
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Doing the opposite is as simple as changing '= 2' to '> 2'

PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab. Please also preview your posts when doing so - the code you posted had no structure at all, all being output as an ordinary string.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete table if cell has data Word VBA: Cannot Edit Range (Delete characters except the first in a table cell) tinfanide Word VBA 3 04-27-2012 09:48 AM
How can I delete the content of a cell in column if the cell value is more than 1000? Learner7 Excel 2 06-27-2011 05:44 AM
Move data from 1 cell to another cell Catalin.B Excel 1 06-25-2011 12:51 PM
How to delete first 6 Digits and one Space from a CELL? Learner7 Excel 3 08-10-2010 04:06 AM
Auto-populate an MS Word table cell with text from a diff cell? dreamrthts Word Tables 0 03-20-2009 01:49 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:36 PM.


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