私は VBA にあまり詳しくありませんが、3 つ以上の条件付き書式を許可するように Excel を変更する必要がありました。
以下のコードをオンラインで見つけて、コンテンツに応じてセルの色を変更し、6 つの異なる値を選択したいと考えています。
私のコードは次のとおりです。
Private Sub Worksheet_Change(ByVal Target As Range)
Set MyPlage = Range("G3:AG115")
For Each Cell In MyPlage
If Cell.Value = "." Then
Cell.Interior.ColorIndex=28
Cell.Font.Bold = True
End If
If Cell.Value = "X1" Then
Cell.Interior.ColorIndex=32
Cell.Font.Bold = True
End If
If Cell.Value = "1X" Then
Cell.Interior.ColorIndex=6
Cell.Font.Bold = True
End If
If Cell.Value = "2X" Then
Cell.Interior.ColorIndex=45
Cell.Font.Bold = True
End If
If Cell.Value = "3X" Then
Cell.Interior.ColorIndex=4
Cell.Font.Bold = True
End If
If Cell.Value = "XY" Then
Cell.Interior.ColorIndex=44
Cell.Font.Bold = True
End If
If Cell.Value = "bt" Then
Cell.Font.ColorIndex=27
Cell.Interior.ColorIndex=27
End If
If Cell.Value = "bl" Then
Cell.Font.ColorIndex=28
Cell.Interior.ColorIndex=28
End If
If Cell.Value <> "bt" And Cell.Value <> "bl" And Cell Value <> "." And Cell.Value <> "X1" And Cell.Value <> "1X" And Cell.Value <> "2X" And Cell.Value <> "3X" And Cell.Value <> "XY" Then
Cell.Interior.ColorIndex=xlNone
End If
Next
End Sub
コンテンツはドロップダウン リストから選択するか、bt と bl を書き込んで、これらの行が強調表示されていることを確認します。
コンテンツを変更しようとすると、Error: 13 Type Mismatch
.
この線
If Cell.Value = "." Then
エラーソースとして強調表示されています(問題はにある可能性があると思いました"."
が、その一連の指示を削除すると、行
If Cell.Value = "X1" Then
が強調表示されます)
私はグーグルで調べて、エラーの場合にループを実行できることをThen Next
確認しました。これを正確にコーディングする方法がわからないため、迅速な修正を行うよりもコーディングの問題を解決したいと考えています。
私がどこで間違っているのか/解決策について誰かが何か考えを持っているなら、それは素晴らしいことです.