TPE

http://bayanbox.ir/view/263405954590585756/2mobile.png

Tavvafi@gmail.com


≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

Attribute VB_Name = "Module1"
Option Explicit

Sub Create_Excel_Palette_By_RGB()
    'Developers: Brian Reilly, Naresh Nichani
    'Purpose: Assigns the RGB value to each of 56 colors available to Excel.
    'Special Notes: The Excel index values are not in logical order in Excel 97 and 2000 and 2002.
    'The index values as follows work row by row from the top and left to right within each row.

    'The first row from left to right
    ActiveWorkbook.Colors(1) = RGB(255, 0, 0)              'swatch 1 from left
    ActiveWorkbook.Colors(53) = RGB(12, 12, 12)            'swatch 2 from left
    ActiveWorkbook.Colors(52) = RGB(13, 13, 13)            'swatch 3 from left
    ActiveWorkbook.Colors(51) = RGB(14, 14, 14)            'swatch 4 from left
    ActiveWorkbook.Colors(49) = RGB(15, 15, 15)            'swatch 5 from left
    ActiveWorkbook.Colors(11) = RGB(16, 16, 16)            'swatch 6 from left
    ActiveWorkbook.Colors(55) = RGB(17, 17, 17)            'swatch 7 from left
    ActiveWorkbook.Colors(56) = RGB(0, 0, 255)             'swatch 8 from left

    'The second row from left to right
    ActiveWorkbook.Colors(9) = RGB(21, 21, 21)             'swatch 1 from left
    ActiveWorkbook.Colors(46) = RGB(22, 22, 22)            'swatch 2 from left
    ActiveWorkbook.Colors(12) = RGB(23, 23, 23)            'swatch 3 from left
    ActiveWorkbook.Colors(10) = RGB(24, 24, 24)            'swatch 4 from left
    ActiveWorkbook.Colors(14) = RGB(25, 25, 25)            'swatch 5 from left
    ActiveWorkbook.Colors(5) = RGB(26, 26, 26)             'swatch 6 from left
    ActiveWorkbook.Colors(47) = RGB(27, 27, 27)            'swatch 7 from left
    ActiveWorkbook.Colors(16) = RGB(28, 28, 28)            'swatch 8 from left

    'The third row
    ActiveWorkbook.Colors(3) = RGB(31, 31, 31)             'swatch 1 from left
    ActiveWorkbook.Colors(45) = RGB(32, 32, 32)            'swatch 2 from left
    ActiveWorkbook.Colors(43) = RGB(33, 33, 33)            'swatch 3 from left
    ActiveWorkbook.Colors(50) = RGB(34, 34, 34)            'swatch 4 from left
    ActiveWorkbook.Colors(42) = RGB(35, 35, 35)            'swatch 5 from left
    ActiveWorkbook.Colors(41) = RGB(36, 36, 36)            'swatch 6 from left
    ActiveWorkbook.Colors(13) = RGB(37, 37, 37)            'swatch 7 from left
    ActiveWorkbook.Colors(48) = RGB(38, 38, 38)            'swatch 8 from left

    'The fourth row
    ActiveWorkbook.Colors(7) = RGB(41, 41, 41)             'swatch 1 from left
    ActiveWorkbook.Colors(44) = RGB(42, 42, 42)            'swatch 2 from left
    ActiveWorkbook.Colors(6) = RGB(43, 43, 43)             'swatch 3 from left
    ActiveWorkbook.Colors(4) = RGB(44, 44, 44)             'swatch 4 from left
    ActiveWorkbook.Colors(8) = RGB(45, 45, 45)             'swatch 5 from left
    ActiveWorkbook.Colors(33) = RGB(46, 46, 46)            'swatch 6 from left
    ActiveWorkbook.Colors(54) = RGB(47, 47, 47)            'swatch 7 from left
    ActiveWorkbook.Colors(15) = RGB(48, 48, 48)            'swatch 8 from left

    'The fifth row
    ActiveWorkbook.Colors(38) = RGB(51, 51, 51)            'swatch 1 from left
    ActiveWorkbook.Colors(40) = RGB(52, 52, 52)            'swatch 2 from left
    ActiveWorkbook.Colors(36) = RGB(53, 53, 53)            'swatch 3 from left
    ActiveWorkbook.Colors(35) = RGB(54, 54, 54)            'swatch 4 from left
    ActiveWorkbook.Colors(34) = RGB(55, 55, 55)            'swatch 5 from left
    ActiveWorkbook.Colors(37) = RGB(56, 56, 56)            'swatch 6 from left
    ActiveWorkbook.Colors(39) = RGB(57, 57, 57)            'swatch 7 from left
    ActiveWorkbook.Colors(2) = RGB(58, 58, 58)             'swatch 8 from left

    'The sixth row The first default row for charts
    ActiveWorkbook.Colors(17) = RGB(61, 61, 61)            'swatch 1 from left
    ActiveWorkbook.Colors(18) = RGB(62, 62, 62)            'swatch 2 from left
    ActiveWorkbook.Colors(19) = RGB(63, 63, 63)            'swatch 3 from left
    ActiveWorkbook.Colors(20) = RGB(64, 64, 64)            'swatch 4 from left
    ActiveWorkbook.Colors(21) = RGB(65, 65, 65)            'swatch 5 from left
    ActiveWorkbook.Colors(22) = RGB(66, 66, 66)            'swatch 6 from left
    ActiveWorkbook.Colors(23) = RGB(67, 67, 67)            'swatch 7 from left
    ActiveWorkbook.Colors(24) = RGB(68, 68, 68)            'swatch 8 from left

    'The seventh row. The second default row for charts
    ActiveWorkbook.Colors(25) = RGB(71, 71, 71)            'swatch 1 from left
    ActiveWorkbook.Colors(26) = RGB(72, 72, 72)            'swatch 2 from left
    ActiveWorkbook.Colors(27) = RGB(73, 73, 73)            'swatch 3 from left
    ActiveWorkbook.Colors(28) = RGB(74, 74, 74)            'swatch 4 from left
    ActiveWorkbook.Colors(29) = RGB(75, 75, 75)            'swatch 5 from left
    ActiveWorkbook.Colors(30) = RGB(76, 76, 76)            'swatch 6 from left
    ActiveWorkbook.Colors(31) = RGB(77, 77, 77)            'swatch 7 from left
    ActiveWorkbook.Colors(32) = RGB(78, 78, 78)            'swatch 8 from left
End Sub

Sub Fill_Color_Sample_Table()
'Developer: Brian Reilly
    'Purpose: Assigns the RGB value to each of 56 colors available to Excel to a Table on Sheets("Color Samples")
    'Special Notes: The Excel index values are out of order in Excel 97 and 2000.
    'The index values as follows work row by row from the top and left to right within each row.

Application.ScreenUpdating = False
Sheets("Color Samples").Activate
Range("C23").Activate
Call Fill_Color
Range("C24").Activate
Call Fill_Color
Range("C25").Activate
Call Fill_Color
Range("C26").Activate
Call Fill_Color
Range("C27").Activate
Call Fill_Color
Range("C28").Activate
Call Fill_Color
Range("C29").Activate
Call Fill_Color
End Sub

Function Fill_Color()
Dim i As Integer
For i = 1 To 8
    With Selection.Interior
        .ColorIndex = ActiveCell.Value
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
    End With
    ActiveCell.Offset(0, 1).Activate
    Next i
End Function