Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-07-2012, 10:07 AM
AlexanderJohnWilley AlexanderJohnWilley is offline Word Macro to find and delete rows that contain adjacent cells containing "." Windows XP Word Macro to find and delete rows that contain adjacent cells containing "." Office 2007
Novice
Word Macro to find and delete rows that contain adjacent cells containing "."
 
Join Date: Nov 2012
Posts: 7
AlexanderJohnWilley is on a distinguished road
Default Word Macro to find and delete rows that contain adjacent cells containing "."

Hello,
I have tables of text that are pasted from excel to word as two column and multiple row tables
A number of the rows have no text and instead have "." just dots in both cells.


For these, I need word macro that will search through the table and find and delete the rows where both adjacent cells contain "." (no text)
thank you!
Reply With Quote
  #2  
Old 11-07-2012, 10:29 AM
gmaxey gmaxey is offline Word Macro to find and delete rows that contain adjacent cells containing "." Windows 7 32bit Word Macro to find and delete rows that contain adjacent cells containing "." Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,228
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

By "dots" do you mean blank space or do you mean periods "."?

If the former then try:
HTML Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRow As Word.Row
For Each oRow In Selection.Tables(1).Rows
  Do While oRow.Cells(1).Range.Characters.First = Chr(32)
    oRow.Cells(1).Range.Characters.First.Delete
  Loop
   Do While oRow.Cells(2).Range.Characters.First = Chr(32)
    oRow.Cells(2).Range.Characters.First.Delete
  Loop
  If Len(oRow.Range) = 6 Then
    oRow.Delete
  End If
Next
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 11-07-2012, 10:31 AM
AlexanderJohnWilley AlexanderJohnWilley is offline Word Macro to find and delete rows that contain adjacent cells containing "." Windows XP Word Macro to find and delete rows that contain adjacent cells containing "." Office 2007
Novice
Word Macro to find and delete rows that contain adjacent cells containing "."
 
Join Date: Nov 2012
Posts: 7
AlexanderJohnWilley is on a distinguished road
Default Word macro to find and delete table rows that have cells containing only ". "

Hello,
I have tables of text that are pasted from excel to word as two column and multiple row tables
A number of the rows have no text and instead have "." just dots in both cells.
For these, I need word macro that will search through the table and find and delete the rows where both adjacent cells contain "." (no text)
thank you!
Reply With Quote
  #4  
Old 11-07-2012, 10:34 AM
AlexanderJohnWilley AlexanderJohnWilley is offline Word Macro to find and delete rows that contain adjacent cells containing "." Windows XP Word Macro to find and delete rows that contain adjacent cells containing "." Office 2007
Novice
Word Macro to find and delete rows that contain adjacent cells containing "."
 
Join Date: Nov 2012
Posts: 7
AlexanderJohnWilley is on a distinguished road
Default

thank you very much

I mean period: .

thanks
Reply With Quote
  #5  
Old 11-07-2012, 10:41 AM
gmaxey gmaxey is offline Word Macro to find and delete rows that contain adjacent cells containing "." Windows 7 32bit Word Macro to find and delete rows that contain adjacent cells containing "." Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,228
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Then change the "32" (two places) to "46"
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/

Last edited by gmaxey; 11-07-2012 at 10:39 PM.
Reply With Quote
  #6  
Old 11-07-2012, 02:04 PM
macropod's Avatar
macropod macropod is offline Word Macro to find and delete rows that contain adjacent cells containing "." Windows 7 64bit Word Macro to find and delete rows that contain adjacent cells containing "." Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,697
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

Try:
Code:
Sub Demo()
Dim i As Long, j As Long, Rng1 As Range, Rng2 As Range
With ActiveDocument
  For i = .Tables.Count To 1 Step -1
    With .Tables(i)
      For j = .Rows.Count To 1 Step -1
        With .Rows(j)
          Set Rng1 = .Cells(1).Range
          Rng1.End = Rng1.End - 1
          Set Rng2 = .Cells(2).Range
          Rng2.End = Rng2.End - 1
          If Rng1.Text = "." Then
            If Rng2.Text = "." Then
              .Delete
            End If
          End If
        End With
      Next
    End With
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 11-07-2012, 05:05 PM
macropod's Avatar
macropod macropod is offline Word Macro to find and delete rows that contain adjacent cells containing "." Windows 7 64bit Word Macro to find and delete rows that contain adjacent cells containing "." Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,697
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

AlexanderJohnWilley: I've just merged your two threads (in different forums on this board) asking for help with the same issue.

I am not amused to find I've wasted my time answering a question I then find has been answered elsewhere - before you even posted the one I answered.

Kindly don't post the same question in multiple threads.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 11-08-2012, 10:15 AM
AlexanderJohnWilley AlexanderJohnWilley is offline Word Macro to find and delete rows that contain adjacent cells containing "." Windows XP Word Macro to find and delete rows that contain adjacent cells containing "." Office 2007
Novice
Word Macro to find and delete rows that contain adjacent cells containing "."
 
Join Date: Nov 2012
Posts: 7
AlexanderJohnWilley is on a distinguished road
Default

Dear All - thank you so much for your help
Reply With Quote
Reply

Tags
delete, macro, table

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
In Excel 2007-After Selecting Visibe Cells-How do I "Copy to Visible cells" Only mag Excel 0 10-28-2012 08:04 PM
How to "hard link" two adjacent cells to a data validation drop down list? Geza59 Excel 10 10-19-2012 11:56 AM
'Linking' entered information to other "cells" from an original "cell" in MS Word Wade Word 6 09-03-2012 05:22 PM
Word Macro to find and delete rows that contain adjacent cells containing "." Macro to delete rows with all empty cells ubns Excel Programming 2 08-14-2012 02:01 AM
Automated "Macro" to delete Tags/Anchors field3 Word VBA 0 02-25-2009 02:53 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:04 AM.


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