Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-27-2022, 04:05 PM
thiennguyen93 thiennguyen93 is offline Select rows Windows 10 Select rows Office 2010
Novice
Select rows
 
Join Date: Jul 2022
Posts: 6
thiennguyen93 is on a distinguished road
Default

Can I have your advice on this. I am working on VBA to look for a multiple text in table and highlight the corresponding rows. I am struggling with it. Can I have your advice?
Reply With Quote
  #2  
Old 07-27-2022, 04:10 PM
thiennguyen93 thiennguyen93 is offline Select rows Windows 10 Select rows Office 2010
Novice
Select rows
 
Join Date: Jul 2022
Posts: 6
thiennguyen93 is on a distinguished road
Default

this is the code I have so far.This code helps me find the list of input "AAAA", "BBBB", "CCCC", "DDDD" and highlight the rows have that value. However; it only highlights the row has 1st input "AAAA", but not "BBBB", "CCCC", and "DDDD" row.

Sub FindMultiItemsInDoc()

Dim objListDoc As Document

Dim objTargetDoc As Document

Dim objParaRange As Range, objFoundRange As Range

Dim objParagraph As Paragraph

Dim strFileName, arrM As String

Dim arr() As String



strFileName = InputBox("Enter the full name of the list document here:")

arr = Split(strFileName, ",")



For i = LBound(arr) To UBound(arr)

arrM = arr(i)



Application.ScreenUpdating = False

With ActiveDocument.Range

With .Find

.ClearFormatting

.Replacement.ClearFormatting

.Text = arrM

.Replacement.Text = ""

.Forward = True

.Wrap = wdFindStop

.Format = False

.MatchWildcards = True

.Execute

End With

Do While .Find.Found

If .Information(wdWithInTable) = True Then

.Rows(1).Range.HighlightColorIndex = wdYellow



End If

.Collapse wdCollapseEnd

.Find.Execute

Loop

End With

Application.ScreenUpdating = True

Next i





End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help, to Select all Rows with color Orange...... Cendrinne Word VBA 0 02-08-2022 02:59 AM
5000 rows, want to select and perform addition on ever 48 rows Rexmaverick Excel 5 06-10-2019 06:29 AM
Need to apply Heading1 to select rows bobk544 Word VBA 3 06-09-2018 05:24 AM
Select rows Select rows w/cells containing given character strings, then sum cell in two other col. LarryHills Excel 1 02-17-2017 03:55 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:10 PM.


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