Macro to Color Fill Cell based on Cell Hex Code Value.

  • I am wanting to have columns "A", "B" and "C" (RGB) values converted into hex codes and fill "E" with the associated color of the hex code. Therefore when I change the RGB numbers I can see what color it is. This will allow me to print a color chart of the ones the cheerleaders use or would like to use. This would be for 20 rows....OZGRID COLORS.xlsx on their shirts. rows.

  • Found this snippet in my 'desk drawer' and I think it's what you need:

  • It works but when I add to active x control it adds

    Private Sub CommandButton1_Click()


    End Sub

    to the macro and will not work with the control button. I can go back and run the macro by itself and it works. How do I keep it from adding the Private Sub CommandButton?

  • When using the ActiveX button, you need to insert the name of the macro you want to run ... like this :



    Code
    Private Sub CommandButton1_Click()
         GenerateColors
    End Sub
  • You can also simply copy the body of the code, like this


  • Thanks Roy. Obviously you are light years ahead of everyone with your vast knowledge of Excel and VBA. Your Website is awesome!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!