[[20230122113009]] 『塗りつぶしの色を変えたい』(nnn) ページの最後に飛ぶ

[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]

 

『塗りつぶしの色を変えたい』(nnn)

お世話になります

a
a
a
a
b
b
b
d
d
d
d
h
h
k
m
m


A列1行目から上記文字が並んでいる場合
文字群で塗りつぶしを行いたいのです
塗りつぶす色はcolorindexの3と6番
赤と黄色で交互に塗りつぶしたく思います
どうかご教示の程よろしくお願い致します

< 使用 Excel:Excel2013、使用 OS:Windows10 >


すみません。

わからなくてわからなくて質問させて頂いたのですが

今できました。

ありがとうございました

Sub test()

    Dim i, r

    Rows(1).Interior.ColorIndex = 3

    For i = 2 To r

        If Cells(i - 1, "A").Value = Cells(i, "A").Value Then

            Rows(i).Interior.ColorIndex = Cells(i - 1, "A").Interior.ColorIndex

        Else

            If Cells(i - 1, "A").Interior.ColorIndex <> 6 Then

                Rows(i).Interior.ColorIndex = 6

            Else

                Rows(i).Interior.ColorIndex = 3

            End If

        End If

    Next i

End Sub
(nnn) 2023/01/22(日) 11:52:01


r = Cells(Rows.Count, "A").End(xlUp).Row

が抜けていました。

すみません。
(nnn) 2023/01/22(日) 11:57:34


コメント返信:

[ 一覧(最新更新順) ]


YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki. Modified by kazu.