現在、モジュールがボタンに接続されたExcelドキュメントがあります。2行のスキャンと比較
Excelの文書では、次のようになります。
ROW | COLUMN C | COLUMN K
1 808 253
2 808 256
3 908 355
4 908 355
5 908 356
6 907 253
7 907 253
私は、次のモジュールがキックオフボタンをクリックすると:
Sub scan()
Dim dataRange As Range
Dim dataRange2 As Range
Dim oneCell As Range
Dim oneCell2 As Range
With ThisWorkbook.Sheets("Resource Info").Range("C:C")
Set dataRange = Range(.Cells(1, 1), .Cells(.Rows.Count, 1).End(xlUp))
End With
With ThisWorkbook.Sheets("Resource Info").Range("K:K")
Set dataRange2 = Range(.Cells(1, 1), .Cells(.Rows.Count, 1).End(xlUp))
End With
For Each oneCell In dataRange
If Application.WorksheetFunction.CountIf(dataRange, oneCell) > 1 Then
For Each oneCell2 In dataRange2
If Application.WorksheetFunction.CountIf(dataRange, oneCell) > 1 And Application.WorksheetFunction.CountIf(dataRange2, oneCell2) <> 1 Then
With oneCell
.EntireRow.Interior.ColorIndex = 6
End With
End If
Next oneCell2
End If
Next oneCell
End Sub
私は行1,2,3を持ってしようとしています、 4,5は列Cと一致するので強調表示されますが、列Kのデータは列Cのグループと一致しません。
私はすべての行が関係なく、列K.
(クイックノートで、あなたもあなたの '' WITH'文で) 'レンジ(使用前に' .'を追加する必要があります) – BruceWayne
あなたがグループ化の基準を詳しく説明してもらえますか?マクロの代わりに、[条件付き書式](http://www.excel-easy.com/data-analysis/conditional-formatting.html)または[sumproduct](https:// exceljet)を使用することもできます。 – Alex
列Cでグループ化が行われるはずです。そのグループ(つまり一致する数値)では、列Kに2つの異なる値が含まれている場合、そのグループの行を強調表示する必要があります。それがうまく説明されることを望みます。 – Alex