1 | initial version |
Here's a code snippet that retrieves and inserts the hex color code of the active cell:
Sub GetActiveCellColor()
Dim activeCellColor As Long
Dim activeCellHexColor As String
activeCellColor = ActiveCell.Interior.Color
activeCellHexColor = Hex(activeCellColor)
'Insert the hex color code into the active cell
ActiveCell.Value = activeCellHexColor
End Sub
This code retrieves the color of the active cell's interior by using the .Color
property of the Interior
object. The color is returned as a Long integer, which is then converted to its hex representation using the Hex
function.
Finally, the hex color code is inserted into the active cell using the .Value
property.