- Excel VBA 質問スレ Part44 [無断転載禁止]©2ch.net
182 :デフォルトの名無しさん[sage]:2016/11/28(月) 22:19:32.48 ID:gVFOtB+w - こんな感じ?
(ただしワークシートの左右端のことは考慮していない) Sub CellColor(ByVal rg As Range) Dim i As Long, j As Long With rg ReDim col(1 To .rows.count, 0 To .Columns.count + 1) As Long For i = 1 To UBound(col, 1) For j = 1 To UBound(col, 2) - 1 If .cells(i, j).Interior.ColorIndex = 6 And .cells(i, j - 1).Interior.ColorIndex = 3 Then col(i, j - 1) = 43 End If If .cells(i, j).Interior.ColorIndex = 6 And .cells(i, j + 1).Interior.ColorIndex = 3 Then col(i, j + 1) = 43 End If Next j Next i For i = 1 To UBound(col, 1) For j = 0 To UBound(col, 2) If col(i, j) = 43 Then .cells(i, j).Interior.ColorIndex = 43 End If Next j Next i End With End Sub
|