Color Grid 65536

Zenwood

Board Regular
Joined
Sep 2, 2017
Messages
67
Hi All,


I am trying to create a Macro that would show all of the possible combinations of Red and Green.
Blue would stay the same. (0)
It should end being a grid of 256 x 256 or 65,536

I tried the code below and I get the first column, but the next step just goes across row 1.

Please help.

------------

Sub Color256x256()


' Make a Grid of all possible combinations or Red and Green. Blue stays the same. Should be 65,536 colors.
' Zenwood - 9.2.17




B = 0


For G = G + 0 To 255


' Draw a column of Red
For R = R + 0 To 255
ActiveCell.Interior.Color = RGB(R, G, B)
ActiveCell.Offset(1, 0).Select ' Move to next row
Next


' Add 1 to green and move to next column
Cells(1, ActiveCell.Column).Select ' move to top
ActiveCell.Offset(0, 1).Select ' Move to nect column
ActiveCell.Interior.Color = RGB(R, G, B)
Next


End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Welcome to the board. Try:
Code:
Sub Color256x256_v1()    
    
    Dim g   As Long
    Dim r   As Long
    Const b As Long = 0
    
    Application.ScreenUpdating = False
    
    For r = 0 To 255
        For g = 0 To 255
            Cells(g + 1, r + 1).Interior.Color = RGB(r, g, b)
        Next g
    Next r
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Thanks. This is exactly what I was looking for.


Welcome to the board. Try:
Code:
Sub Color256x256_v1()    
    
    Dim g   As Long
    Dim r   As Long
    Const b As Long = 0
    
    Application.ScreenUpdating = False
    
    For r = 0 To 255
        For g = 0 To 255
            Cells(g + 1, r + 1).Interior.Color = RGB(r, g, b)
        Next g
    Next r
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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