0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

EXCELの条件付き書式を表示(ダンプ)する

Posted at

EXCELの条件付き書式が、おかしいので調べたい。

EXCELで確認

ウィンドウを大きくしてあげると、式と範囲を見ることができる。
書式ルールの表示(S):を、このワークシートなどにすることで、全体を見ることが可能

image.png

VBAを使ったダンプ(コピペできる)

Copilotに聞いてみた結果

サンプルコード

Sub ExportConditionalFormatting()
    Dim ws As Worksheet
    Dim cf As FormatCondition
    Dim rng As Range
    Dim output As String
    
    Set ws = ActiveSheet
    output = "Cell, Condition, Format" & vbCrLf
    
    For Each rng In ws.UsedRange
        For Each cf In rng.FormatConditions
            output = output & rng.Address & ", " & cf.Formula1 & ", " & cf.Interior.Color & vbCrLf
        Next cf
    Next rng
    
    ' 出力を新しいシートに貼り付け
    Sheets.Add(After:=Sheets(Sheets.Count)).Name = "CF_Export"
    Sheets("CF_Export").Cells(1, 1).Value = output
End Sub

手順

  1. VBA エディタを開く:
    • Alt + F11 を押して VBA エディタを開きます。
  2. 新しいモジュールを追加:
    • 挿入 メニューから モジュール を選択します。
  3. コードを入力:
    • 上記のサンプルコードを新しいモジュールにコピー&ペーストします。
  4. コードを実行:
    • F5 キーを押してコードを実行します。

新しいシートが開いて以下のような出力結果が得られます

Cell, Condition, Format
$N$10, =AND($R10<>"",$S10<>"",$U10<>""), 12632256
$N$10, =AND($R10<>"",$S10<>"",$U10="",$T10>=#REF!), 13434828
$N$10, =OR(AND(1,IF(AND($R10<>"",$R10<#REF!),1,0)),AND($R10<>"",$S10<>"",$U10="",$T10<#REF!)), 13408767
$O$10, =AND($R10<>"",$S10<>"",$U10<>""), 12632256
$O$10, =AND($R10<>"",$S10<>"",$U10="",$T10>=#REF!), 13434828
$O$10, =OR(AND(1,IF(AND($R10<>"",$R10<#REF!),1,0)),AND($R10<>"",$S10<>"",$U10="",$T10<#REF!)), 13408767
$P$10, =AND($R10<>"",$S10<>"",$U10<>""), 12632256
$P$10, =AND($R10<>"",$S10<>"",$U10="",$T10>=#REF!), 13434828
$P$10, =OR(AND(1,IF(AND($R10<>"",$R10<#REF!),1,0)),AND($R10<>"",$S10<>"",$U10="",$T10<#REF!)), 13408767
$Q$10, =AND($R10<>"",$S10<>"",$U10<>""), 12632256
$Q$10, =AND($R10<>"",$S10<>"",$U10="",$T10>=#REF!), 13434828
$Q$10, =OR(AND(1,IF(AND($R10<>"",$R10<#REF!),1,0)),AND($R10<>"",$S10<>"",$U10="",$T10<#REF!)), 13408767
$R$10, =AND($R10<>"",$S10<>"",$U10<>""), 12632256
$R$10, =AND($R10<>"",$S10<>"",$U10="",$T10>=#REF!), 13434828
$R$10, =OR(AND(1,IF(AND($R10<>"",$R10<#REF!),1,0)),AND($R10<>"",$S10<>"",$U10="",$T10<#REF!)), 13408767
$S$10, =AND($R10<>"",$S10<>"",$U10<>""), 12632256
$S$10, =AND($R10<>"",$S10<>"",$U10="",$T10>=#REF!), 13434828
$S$10, =OR(AND(1,IF(AND($R10<>"",$R10<#REF!),1,0)),AND($R10<>"",$S10<>"",$U10="",$T10<#REF!)), 13408767
$T$10, =AND($R10<>"",$S10<>"",$U10<>""), 12632256
$T$10, =AND($R10<>"",$S10<>"",$U10="",$T10>=#REF!), 13434828
$T$10, =OR(AND(1,IF(AND($R10<>"",$R10<#REF!),1,0)),AND($R10<>"",$S10<>"",$U10="",$T10<#REF!)), 13408767
$U$10, =AND($U10="",$V10=1), 65535
$U$10, =AND($R10<>"",$S10<>"",$U10<>""), 12632256
$U$10, =AND($R10<>"",$S10<>"",$U10="",$T10>=#REF!), 13434828
$U$10, =OR(AND(1,IF(AND($R10<>"",$R10<#REF!),1,0)),AND($R10<>"",$S10<>"",$U10="",$T10<#REF!)), 13408767
$V$10, =AND($U10<>"",$V10<1), 65535
$V$10, =AND($R10<>"",$S10<>"",$U10<>""), 12632256
$V$10, =AND($R10<>"",$S10<>"",$U10="",$T10>=#REF!), 13434828
$V$10, =OR(AND(1,IF(AND($R10<>"",$R10<#REF!),1,0)),AND($R10<>"",$S10<>"",$U10="",$T10<#REF!)), 13408767
$W$10, =W10=2, 12566463
$W$10, =W10=1, 9359529
$X$10, =W10=2, 12566463
$X$10, =W10=1, 9359529
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?