4096 Colors

Zenwood

Board Regular
Joined
Sep 2, 2017
Messages
67
Excel can display 16,777,216 colors. 4,096 squared. How would I go about writing a macro that would show every 4,096th color?
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
One way:

Code:
Sub Z()
  Dim iRed          As Long
  Dim iGrn          As Long
  Dim iBlu          As Long
  Dim iRow          As Long
  Dim iCol          As Long

  iRow = 1

  For iRed = 0 To 255 Step 16
    For iGrn = 0 To 255 Step 16
      For iBlu = 0 To 255 Step 16
        iCol = iCol + 1
        If iCol > 64 Then
          iCol = 1
          iRow = iRow + 1
        End If
        Cells(iRow, iCol).Interior.Color = RGB(iRed, iGrn, iBlu)
      Next iBlu
    Next iGrn
  Next iRed
End Sub
 
Upvote 0
This is prettier ...

Code:
Sub Z()
  Dim i             As Long
  Dim j             As Long
  Dim iRed          As Long
  Dim iGrn          As Long
  Dim iBlu          As Long

  For i = 0 To 63
    For j = 0 To 63
      iRed = 16 * (i Mod 16) + 15
      iGrn = j \ 16 + 64 * (i \ 16) + 15
      iBlu = 16 * (j Mod 16) + 15
      Cells(i + 1, j + 1).Interior.Color = RGB(iRed, iGrn, iBlu)
    Next j
  Next i
End Sub
 
Upvote 0
Upper right of 16 16x16 squares:

 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,424
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top