SV-32488r1
Excel ワークシートで 30 個の文字列 (例: , ) のリストを検索し、見つかっSV-33485r1
たときにそれを強調表示するマクロの作成を誰か手伝ってくれませんか?Row
- Office2010を使用しています。
- 私は Excel や VBA の専門家ではないので、どこから始めればよいかわかりません。
- 私が見つけた検索では、1 つの文字列しか検索できませんでした。
よろしくお願いします。
SV-32488r1
Excel ワークシートで 30 個の文字列 (例: , ) のリストを検索し、見つかっSV-33485r1
たときにそれを強調表示するマクロの作成を誰か手伝ってくれませんか?Row
よろしくお願いします。
Public Sub HighlightListedValues()
Dim strConcatList As String
Dim cell As Range
'Creates a string concatenating your list of strings, separated by |s
'e.g. "item1|item2|item3|item4|"
For Each cell In Sheets("List").Range("A1:A30")
strConcatList = strConcatList & cell.Value & "|"
Next cell
'For each used cell in Column A of sheet1, check whether the value in that cell
'is contained within the concatenated string
For Each cell In Intersect(Sheets("Sheet1").Range("A:A"), Sheets("Sheet1").UsedRange)
If InStr(strConcatList, cell.Value) > 0 Then 'InStr returns 0 if the string isn't found
cell.EntireRow.Interior.Color = RGB(255, 0, 0) 'Highlights the row in red if value found
End If
Next cell
End Sub
次の条件に該当する場合、関連する行が赤で強調表示されます。
必要に応じてワークシートと範囲の名前を修正します。たとえば、「データ」という名前のワークシートの A 列から C 列を検索する場合は、次のように修正Sheets("Sheet1").Range("A:A")
します。Sheets("Data").Range("A:C")
お役に立てれば!
単語のリストを見つけてセルを強調表示するマクロを作成しました。コードを使用すると、値の間の空のセルも強調表示されます。また、セルに単語の間に単語が含まれている場合にコードを見つける必要がありました。
例: セル内の単語「Shev」を検索して強調表示するために作成しました。「 was shev in 」のようにセルの中央にある場合は、検索して強調表示する必要があります。
よろしく、
パルティ
以下のコード:
Public Sub HighlightListedValues()
Dim strConcatList As String
Dim cell As Range
For Each cell In Sheets("Bad Words").Range("A1:A30")
strConcatList = strConcatList & cell.Value & "|"
Next cell
For Each cell In Intersect(Sheets("Data").Range("A:Z"), Sheets("data").UsedRange)
If InStr(strConcatList, cell.Value) > 0 Then
cell.Interior.Color = 63125789
End If
Next cell
サブ終了
これは私が現在マクロに持っているものです。
Public Sub HighlightListedValues()
Dim strConcatList As String
Dim cell As Range
'Creates a string concatenating your list of strings, separated by |s
'e.g. "item1|item2|item3|item4|"
For Each cell In Sheets("32281r3|32342r1").Range("E1:E178")
strConcatList = strConcatList & cell.Value & "|"
Next cell
'For each used cell in Column A of sheet1, check whether the value in that cell
'is contained within the concatenated string
For Each cell In Intersect(Sheets("Gap Analysis").Range("E:E"), Sheets("Gap Analysis").UsedRange)
If InStr(strConcatList, cell.Value) > 0 Then 'InStr returns 0 if the string isn't found
cell.EntireRow.Interior.Color = RGB(255, 0, 0) 'Highlights the row in red if value found
End If
Next cell
End Sub