Template_M12_Color

Excel VBA

Excelで使用するカラー見本をマクロで一括作成するコード。
(Microsoft365 64bit環境推奨)

 G-Tool1-A01 からのつづき
 6.【Alt】+【F11】キーを押下し、VBE画面を出す。
 7.【挿入】タブから【標準モジュール】を選択し、標準モジュールを作成。
 8.下記ボックス内をコピーし、標準モジュールに貼り付ける。
 9.モジュール名を【M12_Color】に変更する。

 モジュール名:M12_Color
Option Explicit

'*****************************************************
'    B列12行目から rgbColorを展開
'*****************************************************
Sub ColorRGBSample()

    Dim i As Long
    Dim j As Long
    Dim lngColor As Long
    Dim varEAry1 As Variant
    Dim varEAry2 As Variant
    Dim strEAry1 As Variant
    Dim strEAry2 As Variant
    Dim strJAry1 As Variant
    Dim strJAry2 As Variant
    Dim colW As Variant
    Dim allCnt As Long
    Dim rowNo As Long
    Dim MaxRow As Long        '最終行

    Const TTLROW As Long = 12
    Const STTCOL As Long = 2

    Call StopUpdating

    varEAry1 = Array(rgbBlack, rgbDimGray, rgbGray, rgbDarkGray, _
        rgbSilver, rgbLightGray, rgbGainsboro, rgbWhiteSmoke, rgbWhite, _
        rgbMaroon, rgbDarkRed, rgbBrown, rgbFireBrick, rgbCrimson, _
        rgbRed, rgbOrangeRed, rgbTomato, rgbCoral, rgbLightCoral, _
        rgbDarkSalmon, rgbSalmon, rgbLightSalmon, rgbSandyBrown, rgbSienna, _
        rgbIndianRed, rgbPeru, rgbRosyBrown, rgbTan, rgbBurlyWood, _
        rgbDarkOrange, rgbOrange, rgbDarkGoldenrod, rgbGoldenrod, _
        rgbGold, rgbYellow, rgbDarkKhaki, rgbPaleGoldenrod, rgbKhaki, _
        rgbDarkOliveGreen, rgbOlive, rgbOliveDrab, rgbDarkGreen, rgbGreen, _
        rgbForestGreen, rgbSeaGreen, rgbDarkSeaGreen, rgbLimeGreen, _
        rgbYellowGreen, rgbLime, rgbSpringGreen, rgbMediumSpringGreen, _
        rgbLawnGreen, rgbChartreuse, rgbGreenYellow, rgbLightGreen, _
        rgbPaleGreen, rgbLightSeaGreen, rgbMediumSeaGreen, rgbDarkSlateGray, _
        rgbSlateGray, rgbLightSlateGray, rgbTeal, rgbDarkCyan, rgbLightCyan, _
        rgbCadetBlue, rgbDarkTurquoise, rgbTurquoise)
    varEAry2 = Array(rgbMediumTurquoise, rgbPaleTurquoise, rgbAquamarine, _
        rgbMediumAquamarine, rgbMidnightBlue, rgbNavy, rgbNavyBlue, _
        rgbDarkBlue, rgbMediumBlue, rgbBlue, rgbCornflowerBlue, rgbLightBlue, _
        rgbSteelBlue, rgbLightSteelBlue, rgbRoyalBlue, rgbDodgerBlue, _
        rgbDeepSkyBlue, rgbSkyBlue, rgbLightSkyBlue, rgbAqua, rgbPowderBlue, _
        rgbAliceBlue, rgbIndigo, rgbDarkSlateBlue, rgbSlateBlue, rgbMediumSlateBlue, _
        rgbBlueViolet, rgbDarkViolet, rgbPurple, rgbMediumPurple, _
        rgbDarkMagenta, rgbDarkOrchid, rgbOrchid, rgbMediumOrchid, _
        rgbMediumVioletRed, rgbPaleVioletRed, rgbFuchsia, rgbDeepPink, _
        rgbHotPink, rgbViolet, rgbPlum, rgbThistle, rgbLavender, _
        rgbGhostWhite, rgbPink, rgbLightPink, rgbMistyRose, rgbLavenderBlush, _
        rgbSnow, rgbSeashell, rgbWheat, rgbPeachPuff, rgbNavajoWhite, _
        rgbMoccasin, rgbBisque, rgbBlanchedAlmond, rgbPapayaWhip, _
        rgbAntiqueWhite, rgbLinen, rgbOldLace, rgbFloralWhite, rgbCornsilk, _
        rgbLemonChiffon, rgbBeige, rgbLightGoldenrodYellow, rgbLightYellow, _
        rgbIvory, rgbHoneydew, rgbMintCream, rgbAzure)
    strEAry1 = Array("rgbBlack", "rgbDimGray", "rgbGray", "rgbDarkGray", _
        "rgbSilver", "rgbLightGray", "rgbGainsboro", "rgbWhiteSmoke", "rgbWhite", _
        "rgbMaroon", "rgbDarkRed", "rgbBrown", "rgbFireBrick", "rgbCrimson", _
        "rgbRed", "rgbOrangeRed", "rgbTomato", "rgbCoral", "rgbLightCoral", _
        "rgbDarkSalmon", "rgbSalmon", "rgbLightSalmon", "rgbSandyBrown", "rgbSienna", _
        "rgbIndianRed", "rgbPeru", "rgbRosyBrown", "rgbTan", "rgbBurlyWood", _
        "rgbDarkOrange", "rgbOrange", "rgbDarkGoldenrod", "rgbGoldenrod", _
        "rgbGold", "rgbYellow", "rgbDarkKhaki", "rgbPaleGoldenrod", "rgbKhaki", _
        "rgbDarkOliveGreen", "rgbOlive", "rgbOliveDrab", "rgbDarkGreen", "rgbGreen", _
        "rgbForestGreen", "rgbSeaGreen", "rgbDarkSeaGreen", "rgbLimeGreen", _
        "rgbYellowGreen", "rgbLime", "rgbSpringGreen", "rgbMediumSpringGreen", _
        "rgbLawnGreen", "rgbChartreuse", "rgbGreenYellow", "rgbLightGreen", _
        "rgbPaleGreen", "rgbLightSeaGreen", "rgbMediumSeaGreen", "rgbDarkSlateGray", _
        "rgbSlateGray", "rgbLightSlateGray", "rgbTeal", "rgbDarkCyan", "rgbLightCyan", _
        "rgbCadetBlue", "rgbDarkTurquoise", "rgbTurquoise")
    strEAry2 = Array("rgbMediumTurquoise", "rgbPaleTurquoise", "rgbAquamarine", _
        "rgbMediumAquamarine", "rgbMidnightBlue", "rgbNavy", "rgbNavyBlue", _
        "rgbDarkBlue", "rgbMediumBlue", "rgbBlue", "rgbCornflowerBlue", "rgbLightBlue", _
        "rgbSteelBlue", "rgbLightSteelBlue", "rgbRoyalBlue", "rgbDodgerBlue", _
        "rgbDeepSkyBlue", "rgbSkyBlue", "rgbLightSkyBlue", "rgbAqua", "rgbPowderBlue", _
        "rgbAliceBlue", "rgbIndigo", "rgbDarkSlateBlue", "rgbSlateBlue", "rgbMediumSlateBlue", _
        "rgbBlueViolet", "rgbDarkViolet", "rgbPurple", "rgbMediumPurple", _
        "rgbDarkMagenta", "rgbDarkOrchid", "rgbOrchid", "rgbMediumOrchid", _
        "rgbMediumVioletRed", "rgbPaleVioletRed", "rgbFuchsia", "rgbDeepPink", _
        "rgbHotPink", "rgbViolet", "rgbPlum", "rgbThistle", "rgbLavender", _
        "rgbGhostWhite", "rgbPink", "rgbLightPink", "rgbMistyRose", "rgbLavenderBlush", _
        "rgbSnow", "rgbSeashell", "rgbWheat", "rgbPeachPuff", "rgbNavajoWhite", _
        "rgbMoccasin", "rgbBisque", "rgbBlanchedAlmond", "rgbPapayaWhip", _
        "rgbAntiqueWhite", "rgbLinen", "rgbOldLace", "rgbFloralWhite", "rgbCornsilk", _
        "rgbLemonChiffon", "rgbBeige", "rgbLightGoldenrodYellow", "rgbLightYellow", _
        "rgbIvory", "rgbHoneydew", "rgbMintCream", "rgbAzure")
    strJAry1 = Array("黒", "ディムグレー", "灰色", "濃い灰色", "銀色", "薄い灰色", _
        "ゲーンズボロ", "ホワイトスモーク", "白", "栗色", "濃い赤", "茶", "れんが色", _
        "深紅", "赤", "オレンジレッド", "トマト", "さんご", "薄いさんご", "濃いサーモンピンク", _
        "サーモンピンク", "薄いサーモンピンク", "サンディブラウン", "シェンナ", "インディアンレッド", _
        "ペルー", "ローズブラウン", "タン", "バーリーウッド", "濃いオレンジ", "オレンジ", _
        "濃いゴールデンロッド", "ゴールデンロッド", "ゴールド", "黄", "濃いカーキ", "ペールゴールデンロッド", _
        "カーキ", "濃いオリーブグリーン", "オリーブ", "オリーブドラブ", "濃い緑", "緑", "フォレストグリーン", _
        "シーグリーン", "濃いシーグリーン", "ライムグリーン", "イエローグリーン", "黄緑", "スプリンググリーン", _
        "淡いスプリンググリーン", "若草色", "シャルトルーズ", "グリーンイエロー", "明るい緑", _
        "ペールグリーン", "薄いシーグリーン", "淡いシーグリーン", "濃いスレートグレー", "スレートグレー", _
        "薄いスレートグレー", "青緑", "濃いシアン", "明るい水色", "カデットブルー", "濃いターコイズ", "ターコイズ")
    strJAry2 = Array("淡いターコイズ", "ペールターコイズ", "アクアマリン", "淡いアクアマリン", _
        "ミッドナイトブルー", "ネイビー", "ネイビーブルー", "濃い青", "淡い青", "青", "コーンフラワーブルー", _
        "明るい青", "スチールブルー", "薄いスチールブルー", "ロイヤルブルー", "ドジャーブルー", _
        "深いスカイブルー", "スカイブルー", "薄いスカイブルー", "水色", "パウダーブルー", "アリスブルー", _
        "インディゴ", "濃いスレートブルー", "スレートブルー", "淡いスレートブルー", "青紫", "濃い紫", _
        "紫", "淡い紫", "濃いマゼンタ", "濃いオーキッド", "オーキッド", "淡いオーキッド", _
        "淡いバイオレットレッド", "ペールバイオレットレッド", "明るい紫", "深いピンク", "ホットピンク", _
        "紫色", "プラム", "あざみ色", "ラベンダー", "ゴーストホワイト", "ピンク", "薄いピンク", _
        "ミスティローズ", "ラベンダーブラッシュ", "スノー", "シーシェル", "小麦", "ピーチパフ", _
        "ナバホホワイト", "モカシン", "ビスク", "ブランシュアーモンド", "パパイヤホイップ", "アンティークホワイト", _
        "リネン", "オールドレース", "フローラルホワイト", "コーンシルク", "レモンシフォン", "ベージュ", _
        "薄いゴールデンロッドイエロー", "明るい黄", "アイボリー", "ハニーデュー", "ミントクリーム", "空色")
    colW = Array(0.67, 3.07, 14.8, 7.87, 17.53, 2.93, 2.93, 2.93, 7.2, 9.53, _
                 12.67, 0.67, 8.47, 8.47, 8.47, 8.47, 8.47, 8.47, 8.47, 7.2, 9.53, 11.73)

    If IsSht("Color見本") = False Then
        ThisWorkbook.Worksheets.Add After:=ActiveSheet
    Else
        ActiveSheet.Cells.Clear
        ActiveWindow.FreezePanes = False
    End If

    With ActiveSheet
        .Name = "Color見本"
        .Cells.Font.Name = "Meiryo UI"
        .Cells.Font.Size = 10
        .Cells(TTLROW, STTCOL) = "NO"
        .Cells(TTLROW, STTCOL + 1) = "色名"
        .Cells(TTLROW, STTCOL + 2) = "例:背景色"
        .Cells(TTLROW, STTCOL + 3) = "定数"
        .Cells(TTLROW, STTCOL + 4) = "R"
        .Cells(TTLROW, STTCOL + 5) = "G"
        .Cells(TTLROW, STTCOL + 6) = "B"
        .Cells(TTLROW, STTCOL + 7) = "Color値"
        .Cells(TTLROW, STTCOL + 8) = "HEX(16進数)"
        .Cells(TTLROW, STTCOL + 9) = "VBA使用時は""&H"""
        .Range(.Cells(TTLROW, STTCOL), .Cells(TTLROW, STTCOL + 9)) _
            .Interior.Color = 16768716
        rowNo = TTLROW
        For i = 0 To UBound(strEAry1)
            rowNo = rowNo + 1
            .Cells(rowNo, 3) = strJAry1(i)
            .Cells(rowNo, 4).Interior.Color = varEAry1(i)
            .Cells(rowNo, 5) = CStr(strEAry1(i))
        Next i
        For i = 0 To UBound(strEAry2)
            rowNo = rowNo + 1
            .Cells(rowNo, 3) = strJAry2(i)
            .Cells(rowNo, 4).Interior.Color = varEAry2(i)
            .Cells(rowNo, 5) = CStr(strEAry2(i))
        Next i
        MaxRow = rowNo - TTLROW - 1
        rowNo = TTLROW
        For i = 0 To MaxRow
            rowNo = rowNo + 1
            .Cells(rowNo, STTCOL) = i + 1
            '現在の色を変数に格納
            lngColor = .Cells(rowNo, STTCOL + 2).Interior.Color
            .Cells(rowNo, STTCOL + 4).Value = lngColor Mod 256
            .Cells(rowNo, STTCOL + 5).Value = (lngColor \ 256) Mod 256
            .Cells(rowNo, STTCOL + 6).Value = lngColor \ (256 ^ 2)
            .Cells(rowNo, STTCOL + 7) = lngColor
            .Cells(rowNo, STTCOL + 8).Value = "#" & WorksheetFunction.Dec2Hex(lngColor, 6)
            .Cells(rowNo, STTCOL + 9).Value = "&H" & WorksheetFunction.Dec2Hex(lngColor, 6)
        Next i

        Call ColorConstant
        Call ColorIndex
        Call UDColor
        Call SetC1

        For j = 0 To 11
            .Columns(j + 1).ColumnWidth = colW(j)
        Next j

        .Columns(2).HorizontalAlignment = xlCenter
        .Columns(13).HorizontalAlignment = xlCenter

        'ウィンドウ枠の固定
        .Range("C13").Select

        ActiveWindow.FreezePanes = True

        '枠線を非表示にする
        ActiveWindow.DisplayGridlines = False

        '■スクロールして先頭に移動する
        Application.Goto reference:=.Range("A1"), Scroll:=True
    End With
    Call Updating
End Sub

'【Color見本】シートを作成
'*****************************************************
'    M列2行目から 定数色を展開
'*****************************************************
Sub ColorConstant()

    Dim i As Long
    Dim lngColor As Long
    Dim strAry As Variant
    Dim strAry2 As Variant
    Dim lngAry As Variant

    Const TTLROW As Long = 2
    Const STTCOL As Long = 13

    lngAry = Array(1, 5, 8, 4, 7, 3, 2, 6)
    strAry = Array("黒", "青", "シアン", "緑", "マゼンタ", "赤", "白", "黄")
    strAry2 = Array("vbBlack", "vbBlue", "vbCyan", "vbGreen", "vbMagenta", _
              "vbRed", "vbYellow", " vbWhite")

    With ActiveSheet
        .Cells(TTLROW, STTCOL) = "ColorIndex"
        .Cells(TTLROW, STTCOL + 1) = "色名"
        .Cells(TTLROW, STTCOL + 2) = "例:背景色"
        .Cells(TTLROW, STTCOL + 3) = "定数"
        .Cells(TTLROW, STTCOL + 4) = "R"
        .Cells(TTLROW, STTCOL + 5) = "G"
        .Cells(TTLROW, STTCOL + 6) = "B"
        .Cells(TTLROW, STTCOL + 7) = "Color値"
        .Cells(TTLROW, STTCOL + 8) = "HEX(16進数)"
        .Cells(TTLROW, STTCOL + 9) = "VBA使用時は""&H"""
        With .Range(.Cells(TTLROW, STTCOL), .Cells(TTLROW, STTCOL + 9))
            .Interior.Color = 16768716
            .HorizontalAlignment = xlCenter
        End With

        For i = 1 To 8
            .Cells(i + TTLROW, STTCOL).Value = lngAry(i - 1)
            .Cells(i + TTLROW, STTCOL + 1).Value = strAry(i - 1)
            .Cells(i + TTLROW, STTCOL + 2).Interior.ColorIndex = .Cells(i + TTLROW, STTCOL).Value
            lngColor = .Cells(i + TTLROW, STTCOL + 2).Interior.Color
            .Cells(i + TTLROW, STTCOL + 3).Value = strAry2(i - 1)
            .Cells(i + TTLROW, STTCOL + 4).Value = lngColor Mod 256
            .Cells(i + TTLROW, STTCOL + 5).Value = (lngColor \ 256) Mod 256
            .Cells(i + TTLROW, STTCOL + 6).Value = lngColor \ (256 ^ 2)
            .Cells(i + TTLROW, STTCOL + 7) = lngColor
            .Cells(i + TTLROW, STTCOL + 8).Value = "#" & WorksheetFunction.Dec2Hex(lngColor, 6)
            .Cells(i + TTLROW, STTCOL + 9).Value = "&H" & WorksheetFunction.Dec2Hex(lngColor, 6)
        Next i

    End With

End Sub

'*****************************************************
'    M列12行目から ColorIndexの色を展開
'*****************************************************
Sub ColorIndex()

    Dim i As Long
    Dim lngColor As Long
    Dim strAry As Variant

    Const TTLROW As Long = 12
    Const STTCOL As Long = 13

    strAry = Array("黒", "白", "赤", "明るい緑", "青", "黄", "ピンク", "水色", "濃い赤", _
        "緑", "濃い青", "濃い黄", "紫", "青緑", "25%灰色", "50%灰色", "グレー", "プラム", "アイボリー", _
        "薄い水色", "濃い紫", "コーラル", "オーシャンブルー", "アイスブルー", "濃い青", "ピンク", "黄", "水色", _
        "紫", "濃い赤", "青緑", "青", "スカイブルー", "薄い水色", "薄い緑", "薄い黄色", "ペールブルー", _
        "ローズ", "ラベンダー", "ベージュ", "薄い青", "アクア", "ライム", "ゴールド", "薄いオレンジ", "オレンジ", _
        "ブルーグレー", "40%灰色", "濃い青緑", "シーグレー", "濃い緑", "オリーブ", "茶", "プラム", "インディゴ", _
        "80%灰色", "")

    With ActiveSheet
        .Cells(TTLROW, STTCOL) = "ColorIndex"
        .Cells(TTLROW, STTCOL + 1) = "色名"
        .Cells(TTLROW, STTCOL + 2) = "例:背景色"
        .Cells(TTLROW, STTCOL + 3) = "色番号"
        .Cells(TTLROW, STTCOL + 4) = "R"
        .Cells(TTLROW, STTCOL + 5) = "G"
        .Cells(TTLROW, STTCOL + 6) = "B"
        .Cells(TTLROW, STTCOL + 7) = "Color値"
        .Cells(TTLROW, STTCOL + 8) = "HEX(16進数)"
        .Cells(TTLROW, STTCOL + 9) = "VBA使用時は""&H"""

        With .Range(.Cells(TTLROW, STTCOL), .Cells(TTLROW, STTCOL + 9))
            .Interior.Color = 16768716
            .HorizontalAlignment = xlCenter
        End With

        For i = 1 To 56
            .Cells(i + TTLROW, STTCOL).Value = i
            .Cells(i + TTLROW, STTCOL + 1).Value = strAry(i - 1)
            .Cells(i + TTLROW, STTCOL + 2).Interior.ColorIndex = .Cells(i + TTLROW, STTCOL).Value
            lngColor = .Cells(i + TTLROW, STTCOL + 2).Interior.Color
            .Cells(i + TTLROW, STTCOL + 3).Value = lngColor
            .Cells(i + TTLROW, STTCOL + 4).Value = lngColor Mod 256
            .Cells(i + TTLROW, STTCOL + 5).Value = (lngColor \ 256) Mod 256
            .Cells(i + TTLROW, STTCOL + 6).Value = lngColor \ (256 ^ 2)
            .Cells(i + TTLROW, STTCOL + 7) = lngColor
            .Cells(i + TTLROW, STTCOL + 8).Value = "#" & WorksheetFunction.Dec2Hex(lngColor, 6)
            .Cells(i + TTLROW, STTCOL + 9).Value = "&H" & WorksheetFunction.Dec2Hex(lngColor, 6)
        Next i

    End With

End Sub

'【Color見本】シートを作成
'*****************************************************
'    M列71行目から 定数色を展開
'*****************************************************
Sub UDColor()

    Dim i As Long
    Dim lngColor As Long
    Dim strAry As Variant
    Dim strAry2 As Variant
    Dim lngAry As Variant

    Const TTLROW As Long = 71
    Const STTCOL As Long = 13

    lngAry = Array(19455, 61951, 8040195, 16734720, 16761933, _
            8552703, 43766, 10027161, 16512, 12569343, 8454143, 5632728, _
            16770239, 8440575, 11065719, 15117513, 16777215, 13355208, _
            10391940, 0)
    strAry = Array("赤", "黄色", "緑", "青", "空色", "ピンク", "オレンジ", _
        "紫", "茶色", "明るいピンク", "クリーム", "明るい黄緑", "明るい空色", "ベージュ", _
        "明るい緑", "明るい紫", "白", "明るいグレー", "グレー", "黒")
    strAry2 = Array("アクセントカラー", "ベースカラー", "無彩色")

    With ActiveSheet
        .Cells(TTLROW, STTCOL) = "色定義"
        .Cells(TTLROW, STTCOL + 1) = "色名"
        .Cells(TTLROW, STTCOL + 2) = "例:背景色"
        .Cells(TTLROW, STTCOL + 3) = "色番号"
        .Cells(TTLROW, STTCOL + 4) = "R"
        .Cells(TTLROW, STTCOL + 5) = "G"
        .Cells(TTLROW, STTCOL + 6) = "B"
        .Cells(TTLROW, STTCOL + 7) = "Color値"
        .Cells(TTLROW, STTCOL + 8) = "HEX(16進数)"
        .Cells(TTLROW, STTCOL + 9) = "VBA使用時は""&H"""
        With .Range(.Cells(TTLROW, STTCOL), .Cells(TTLROW, STTCOL + 9))
            .Interior.Color = 16768716
            .HorizontalAlignment = xlCenter
        End With
        .Range("M70").Value = "カラーユニバーサルデザイン"
        .Range("M72:M80").Value = strAry2(0)
        .Range("M81:M87").Value = strAry2(1)
        .Range("M88:M91").Value = strAry2(2)

        For i = 1 To 20
            .Cells(i + TTLROW, STTCOL + 1).Value = strAry(i - 1)
            lngColor = CLng(lngAry(i - 1))
            .Cells(i + TTLROW, STTCOL + 2).Interior.Color = lngColor
            .Cells(i + TTLROW, STTCOL + 3).Value = lngAry(i - 1)
            .Cells(i + TTLROW, STTCOL + 4).Value = lngColor Mod 256
            .Cells(i + TTLROW, STTCOL + 5).Value = (lngColor \ 256) Mod 256
            .Cells(i + TTLROW, STTCOL + 6).Value = lngColor \ (256 ^ 2)
            .Cells(i + TTLROW, STTCOL + 7) = lngColor
            .Cells(i + TTLROW, STTCOL + 8).Value = "#" & WorksheetFunction.Dec2Hex(lngColor, 6)
            .Cells(i + TTLROW, STTCOL + 9).Value = "&H" & WorksheetFunction.Dec2Hex(lngColor, 6)
        Next i

    End With

End Sub

'【Color見本】シートを作成
'*****************************************************
'    タイトル周辺設定
'*****************************************************
Sub SetC1()

    With ActiveSheet
        .Range("C2").Value = "Color見本"
        With .Range("B2:K3")
            .Interior.Color = 16229988
            With .Borders(xlEdgeBottom)
                .LineStyle = xlContinuous
                .ThemeColor = 10
                .TintAndShade = 0
                .Weight = xlMedium
            End With
            With .Borders(xlEdgeRight)
                .LineStyle = xlContinuous
                .ThemeColor = 10
                .TintAndShade = 0
                .Weight = xlThin
            End With
        End With
        With .Range("C2:I3")
            .Merge
            With .Font
                .Color = vbWhite
                .Name = "Meiryo UI"
                .Size = 16
                .Bold = True
            End With
            .HorizontalAlignment = xlLeft
            .VerticalAlignment = xlBottom
            .InsertIndent 3
        End With
        .Range("C5").Value = "Range(""A5"").Interior.Color = xlNone    '背景色無色"
        .Range("C6").Value = "Range(""A1"").Font.Color = ColorConstants.vbCyan"
        .Range("C7").Value = "Range (""A3"").Interior.Color=RGB(lngR,lngG,lngB)"
        .Range("C8").Value = "Range (""A4"").Interior.Color =rgbSilber"
        .Range("C9").Value = "Range(""A5"") Interior.ColorIndex =4"
        .Range("C10").Value = "Worksheets(""Sheet1"").Tab.ColorIndex = 3"
        .Range("J5").Interior.Color = RGB(255, 255, 102)
        .Range("J6").Interior.Color = rgbGhostWhite
        .Range("J7").Interior.Color = rgbLavenderBlush
        .Range("J8").Interior.Color = rgbMistyRose
        .Range("J9").Interior.Color = 16768716
        .Range("J10").Interior.Color = 16249582
        .Range("K5").Value = "RGB(255,255,102)"
        .Range("K6").Value = "rgbGhostWhite"
        .Range("K7").Value = "rgbLavenderBlush"
        .Range("K8").Value = "rgbMistyRose"
        .Range("K9").Value = "16768716"
        .Range("K10").Value = "16249582"
        With .Range("C5:K10")
            .Font.Size = 10
            .Font.Color = RGB(84, 84, 84)
        End With
    End With

End Sub

'*****************************************************
'    アクティブセル 色取得
'*****************************************************
Public Sub GetRngColor()
    Debug.Print "背景色:" & ActiveCell.Interior.Color
    Debug.Print "文字色:" & ActiveCell.Font.Color
End Sub

コメント

タイトルとURLをコピーしました