Excel - A macro to get the equivalent numerical codes for colors

December 2016


This macro allows you to get a color code, you can modify it to your convenience:

Sub distri_color()   
  Dim Lign As Integer  
  For Lign = 1 To 12   
    Worksheets(1).Range("C" & Lign).Value = Worksheets(1).Range("B" & Lign).Interior.Color   
  Next Lign  
End Sub
  • 'Replace 12 by the number of lines you want to process.
  • 'Replace "C" by the column you want to use for the result (color code).
  • 'Replace "B" by the column that contains the color to be filtered.


Related :

This document entitled « Excel - A macro to get the equivalent numerical codes for colors » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.