Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 11-12-2020, 07:46 PM
Guessed's Avatar
Guessed Guessed is offline Search in Nested Tables to Delete Rows Windows 10 Search in Nested Tables to Delete Rows Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Greg

This is a very interesting example of a recursive function to return a collection. I'm intrigued that it works to build a collection which appears to be recreated from New with each recursion. I'm going to have to study this to work how you did that. I would have expected the collection to be created in the Sub and then passed in to the function for filling.

On a speed front, I would think that looping through all the tables appears to be less efficient than just searching for the text and then checking if it happens to be in a nested table. Would this code not do the same thing without the recursion?
Code:
Sub FlyTheNest()
  Dim aRng As Range
  Set aRng = ActiveDocument.Range
  With aRng.Find
    .ClearFormatting
    .Text = "XXX text"
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    While .Execute
      'aRng.Select    'testing purposes only
      If aRng.Information(wdWithInTable) Then
        If aRng.Tables(1).NestingLevel > 1 Then
          aRng.Rows(1).Delete
        End If
      End If
    Wend
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Tags
nested table, search nested table

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting Nested Tables LBruce Word VBA 3 01-20-2020 09:07 AM
Search in Nested Tables to Delete Rows Delete all empty rows in all tables fbucaram Word VBA 6 01-05-2018 03:04 PM
Nested tables. Count rows NevilleT Word VBA 9 05-10-2017 05:22 AM
Search in Nested Tables to Delete Rows Macro to delete all empty rows from all tables braddgood Word VBA 15 10-02-2015 01:54 PM
Nested vlookup with varable tables! Dave Jones Excel 0 08-30-2012 09:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:25 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