Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

16
  • 1
    \$\begingroup\$ You could probably do better with ColorIndex as that's a number from 3 to 8 here, which you could encode in a string or something. \$\endgroup\$ Commented Apr 17, 2019 at 8:32
  • \$\begingroup\$ @Neil - Indeed :) I was able to get it quite a bit shorter using that. Thanks for the tip. \$\endgroup\$ Commented Apr 17, 2019 at 17:15
  • \$\begingroup\$ I didn't see anything that stops you from changing this to Sub F() and End Sub for more savings. \$\endgroup\$ Commented Apr 18, 2019 at 12:46
  • 1
    \$\begingroup\$ Don't make it a function, and run this in the Immediate Window to drop 21 bytes: for i=1 To 3:for j=1 To 3:Cells(i,j).Interior.ColorIndex=Mid("367408005",i*j,1):next j,i \$\endgroup\$ Commented Apr 18, 2019 at 15:40
  • 1
    \$\begingroup\$ You can also remove quotes from the string, VBA will coerce the number into a string automatically. \$\endgroup\$ Commented Apr 18, 2019 at 16:16