chris1993
07-23-2015, 11:46 AM
Hi, I have a macro that I run in excel. It finds words from a list (inside the macro), then makes them bold and red. Right now the macro is set to run through an excel workbook. I need it to do the exact same thing, but through a word doc.
Can someone help me adjust the macro to do so?
Thanks!
here is what I have:
Sub ambiguitycheckv5()
Dim fnd, r As Range, i&, wsh As Worksheet, wrd
word_list1 = Array("above", "below", "it", "such", "the previous", "them", "these", "they", "this", "those", "all", "any", "appropriate", "custom", "efficient", "every", "few", "frequent", "improved", "infrequent", "intuitive", "invalid", "many", "most", "normal", "orginary", "rare", "same", "some", "the complete", "the entire", "transparent", "typical", "usual", "standard", "valid", "accordingly", "almost", "approximately", "by and large", "commonly", "customarily", "efficiently", "frequently", "generally", "hardly ever", "in general", "seamless", "several", "infrequently", "intuitively", "just about", "more often than not", "more or less", "mostly", "nearly", "normally", "not quite", "often", "on the odd occasion", "ordinarily", "rarely", "roughly", "seamlessly", "seldom", "similarily", "sometime", "somewhat", "transparently", "typically", "usually", "the application", "the component", "the date", "the database", "derive", "the field", "determine", "edit", "the file", "the frame", "enable")
word_list2 = Array("the information", "improve", "the message", "indicate", "the module", "the page", "manipulate", "match", "the rule", "maximize", "the screen", "may", "the status", "might", "minimize", "the system", "the table", "modify", "the value", "optimize", "the window", "perform", "adjust", "process", "produce", "provide", "alter", "amend", "calculate", "support", "update", "validate", "verify", "change", "compare", "compute", "convert", "create", "customize")
word_list = Split(Join(word_list1, Chr(1)) & Chr(1) & Join(word_list2, Chr(1)), Chr(1))
Application.ScreenUpdating = False
With CreateObject("VBScript.RegExp")
.Global = True: .IgnoreCase = True
For Each wsh In ThisWorkbook.Sheets
For Each wrd In word_list
.Pattern = "\b" & wrd & "\b"
For Each r In wsh.Range("B2:G9").Cells
If .Test(r) Then
With .Execute(r)
For i = 0 To .Count - 1
With r.Characters(.Item(i).FirstIndex + 1, .Item(i).Length).Font
.Bold = True: .Color = vbRed
End With
Next
End With
End If
Next r
Next wrd
Next wsh
End With
Application.ScreenUpdating = True
End Sub
Can someone help me adjust the macro to do so?
Thanks!
here is what I have:
Sub ambiguitycheckv5()
Dim fnd, r As Range, i&, wsh As Worksheet, wrd
word_list1 = Array("above", "below", "it", "such", "the previous", "them", "these", "they", "this", "those", "all", "any", "appropriate", "custom", "efficient", "every", "few", "frequent", "improved", "infrequent", "intuitive", "invalid", "many", "most", "normal", "orginary", "rare", "same", "some", "the complete", "the entire", "transparent", "typical", "usual", "standard", "valid", "accordingly", "almost", "approximately", "by and large", "commonly", "customarily", "efficiently", "frequently", "generally", "hardly ever", "in general", "seamless", "several", "infrequently", "intuitively", "just about", "more often than not", "more or less", "mostly", "nearly", "normally", "not quite", "often", "on the odd occasion", "ordinarily", "rarely", "roughly", "seamlessly", "seldom", "similarily", "sometime", "somewhat", "transparently", "typically", "usually", "the application", "the component", "the date", "the database", "derive", "the field", "determine", "edit", "the file", "the frame", "enable")
word_list2 = Array("the information", "improve", "the message", "indicate", "the module", "the page", "manipulate", "match", "the rule", "maximize", "the screen", "may", "the status", "might", "minimize", "the system", "the table", "modify", "the value", "optimize", "the window", "perform", "adjust", "process", "produce", "provide", "alter", "amend", "calculate", "support", "update", "validate", "verify", "change", "compare", "compute", "convert", "create", "customize")
word_list = Split(Join(word_list1, Chr(1)) & Chr(1) & Join(word_list2, Chr(1)), Chr(1))
Application.ScreenUpdating = False
With CreateObject("VBScript.RegExp")
.Global = True: .IgnoreCase = True
For Each wsh In ThisWorkbook.Sheets
For Each wrd In word_list
.Pattern = "\b" & wrd & "\b"
For Each r In wsh.Range("B2:G9").Cells
If .Test(r) Then
With .Execute(r)
For i = 0 To .Count - 1
With r.Characters(.Item(i).FirstIndex + 1, .Item(i).Length).Font
.Bold = True: .Color = vbRed
End With
Next
End With
End If
Next r
Next wrd
Next wsh
End With
Application.ScreenUpdating = True
End Sub