title: HEX color codes in VBA
body: <p>Hi I am using HEX() to indicate the color of specific cells in excel. I did 4 examples and results given are confusing. 2 of 4 gave 6-digits HEX code and the other 2 gave 4-digits HEX code. I did a search online and seems like HEX code has to be 6-digits? So what do these 4-digits code stand for?</p>
  
  <p>I also put these 4-digits code in <a href="https://www.color-hex.com/" rel="nofollow noreferrer">https://www.color-hex.com/</a> and no results were found.</p>
  
  <pre><code>Sub showcolor()
  
  Debug.Print Hex(ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count).Cells(10, "AB").Interior.Color)
  Debug.Print Hex(ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count).Cells(34, "AB").Interior.Color)
  Debug.Print Hex(ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count).Cells(13, "AB").Interior.Color)
  Debug.Print Hex(ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count).Cells(12, "AB").Interior.Color)
  
  End Sub
  </code></pre>
  
  <p>The results given are</p>
  
  <p>C0FF
  FFFF
  F0B000
  FFFFFF</p>