開いている複数のワークブックで文字列を検索し、行に色を付ける方法。文字列はすべてのシートで複製でき、列 A、B、または C に表示できます。このコードを他のワークブックに適用できますか? 1 つのワークブックで次のコードを見つけました。
Sub Search_String()
Dim SearchString As String
Dim SearchRange As Range, cl As Range
Dim Escolhe_Cor As Long
Dim FirstFound As String
Dim sh As Worksheet
' Set Search value
SearchString = InputBox("Digite o número a ser procurado")
Escolhe_Cor = InputBox("Escolha uma cor para destacar esse número. De 3 a 56")
Application.FindFormat.Clear
' loop through all sheets
For Each sh In ActiveWorkbook.Worksheets
' Find first instance on sheet
Set cl = sh.Cells.Find(What:=SearchString, _
After:=sh.Cells(1, 1), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Not cl Is Nothing Then
' if found, remember location
FirstFound = cl.Address
' format found cell
Do
cl.EntireRow.Font.Bold = True
cl.EntireRow.Interior.ColorIndex = Escolhe_Cor
' find next instance
Set cl = sh.Cells.FindNext(After:=cl)
' repeat until back where we started
Loop Until FirstFound = cl.Address
End If
Next
End Sub