In this article, we are glad to show you 3 quick ways to find specific text in your Word tables only.
Utilizing the “Find and Replace”, a built-in function in Word, you can search for and find a specific text in a long document. As you see, this is based on the entire document. How about we limit the searching range to Word tables only? Read on to see details.
Method 1: Find Text in Selection
- First of all, manually select one or more tables in document.
- Then click drop-down button next to “Find” command under “Home” tab.
- Choose “Advanced Find” to open “Find and Replace” dialog box.
- Enter finding text in “Find what” text box.
- Click “Find In” tab and choose “Current Selection”.
Word will find text in your selection only.
Method 2: Find Text in a Table
Besides the usual way, you can choose to run macro to do more customized tasks.
- First off, put cursor inside a table where you want to find text.
- Then press “Alt+ F11” to open VBA editor.
- Click “Normal” on the left column.
- Then click “Insert” and choose “Module”.
- Next double click the module to open it.
- Paste following codes into module:
Sub FindInATable() Dim strText As String strText = InputBox("Enter finding text here: ") Application.ScreenUpdating = False If Selection.Information(wdWithInTable) = True Then With Selection.Tables(1).Range With .Find .ClearFormatting .Text = strText .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute End With Do While .Find.Found .Cells(1).Shading.BackgroundPatternColorIndex = wdBrightGreen On Error GoTo handler .Collapse wdCollapseEnd .Find.Execute Loop End With Else MsgBox ("Put cursor inside a table first.") Exit Sub End If handler: Exit Sub Application.ScreenUpdating = True End Sub
- Lastly, click “Run”. Enter a text inside the input box and click “OK” to proceed.
Method 3: Find Text in All Tables in a Document
- First and foremost, repeat steps in method 2 to install and run a macro.
- Next replace that macro with this one:
Sub FindTextsInAllTables() Dim strText As String strText = InputBox("Enter finding text here: ") Application.ScreenUpdating = False With Selection .HomeKey Unit:=wdStory With Selection.Find .ClearFormatting .Text = strText .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute End With Do While .Find.Found = True If .Information(wdWithInTable) = True Then .Cells(1).Shading.BackgroundPatternColorIndex = wdBrightGreen End If .Collapse wdCollapseEnd .Find.Execute Loop End With Application.ScreenUpdating = True End Sub
- Similarly, type searching text inside the input box. And click “OK” to proceed.
Rescue Your Data in Time
Once you get compromised data, keep in mind that they are recoverable. So never give up before trying. Under such circumstances, you need to check your latest backup, if any. There is a good chance to have some of your data back. Besides, you can always resort to doc fix tool to recover data.
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including damaged xls and pdf repair software products. For more information visit www.datanumen.com