1

基本的に列Aの値を同じ色で強調表示し、青と白の色を交互に表示するマクロを作成しようとしています。したがって、正確な値は色ごとにグループ化されます。

これが理にかなっていると思いますか?現時点では、強調表示を手動で行っています (ただし、12000 行以上あるため、賢明な考えではありません)。私はまだ VBA に慣れていないので、まだまだ勉強中です。

したがって、基本的にこのマクロは、列 A のセル x の値が同じ列のセル x+1 の値と同じであることを確認します。そうであれば、それらは白くハイライトされます。セル x+2 が x と同じ値ではなく、セル x+2 と x+3 が同じ値である場合、それらは青色で強調表示されます。WHOLE ROWに広がる色が必要

これがビジュアルです(行全体が色付けされていると想像してください):

ビジュアル

4

1 に答える 1

0

This will highlight the second cell in the column. The color might now be the extact color you want though.

EDIT2: added the definition for testcell1, first,Second and Added Report as worksheet code

edit 3: changed <> to =

Sub runthis()


'Dim row As Integer

Dim TestCell As String
Dim first As String
Dim Second As String

Dim TestCell1 As String
Dim lastcell As Integer

Sheets("sheet1").Select

Dim Report As Worksheet
Set Report = Excel.Worksheets("Sheet1")


lastcell = Sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).row

For row = 1 To lastcell
    TestCell = "A" & CInt(row)
    TestCell1 = "A" & (CInt(row) + 1)
    first = Range(TestCell).Value
    Second = Range(TestCell1).Value

    If first = Second Then
        Report.Cells(row, 1).Interior.ColorIndex = 3

    End If
Next row
End Sub
于 2013-06-06T13:45:44.437 に答える