VBAの新機能です。私は、赤で同じ文字列を含むシートセルの2つの列のセルをハイライト表示するコードを作成しようとしています。そして、2つの赤いセルを持つ行を含むすべての行を削除します。2つのセルの色を比較して行を削除するVBA
私はこれについて非常に新しく、これは私がこれまでに思いついたことです。最初のステージはうまく動作しますが、その後、セルの色を比較しようとしましたが、動作しませんでした。
Option Explicit
Sub Macro1()
Dim WhatFor As String
WhatFor = InputBox("Enter your search word to highlight", "Search Criteria")
If WhatFor = Empty Then Exit Sub
Range("A1").Select
Selection.CurrentRegion.Select
Selection.FormatConditions.Add Type:=xlTextString, String:=WhatFor, _
TextOperator:=xlContains
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Sub Macro2()
Dim i As Integer
Dim cell As Range
cell = ActiveWorkbook.ActiveSheet.Range
i = 1
Do While Cells("A, i").Value <> ""
If cell("A, i").Interior And cell("F, i").Interior = 13551615 Then:
Rows(i).EntireRow.Delete
End If
i = i + 1
Loop
End Sub
は、それが細胞を着色する全く意味がありませんか?ちょうど行を削除してください – jsotola
あなたはおそらく正しいですが、文字列の2つの部分を比較することは私のために複雑です。 **実際には** Equal **ではありませんが、ほとんどの場合、値は「類似」です。 – yaeer
削除行は、指定された文字列が複数回、同じセル内で、同じ行内で、その文字列が大文字と小文字を区別しない場合に検出されましたか?別の文字列として存在し、長い文字列内の部分文字列ではありませんか?文字列はセル内の唯一の項目ですか? – QHarr