매크로/모듈(Module)

Get color picker RGB value

고추탄 2022. 10. 22. 19:12

Private Sub PColor_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

   Dim dColor As Double
  Dim R_Color As Double
  Dim G_Color As Double
  Dim B_Color As Double

  dColor = PickColor(Me.lb_PColor.BackColor)
    
  With Me.lb_PColor
                   .BackColor = dColor
                   .ForeColor = dColor
                   .Caption = dColor
  End With
  
  R_Color = (dColor Mod 256)
  G_Color = ((dColor \ 256) Mod 256)
  B_Color = (((dColor \ 256) \ 256) Mod 256)

End Sub

Function PickColor(Optional Dbl_ColorBefore As Double = 0) As Double

  Dim ExcelColorSaved As Double
    
  Dim R_Color As Double
  Dim G_Color As Double
  Dim B_Color As Double
    
  Const ColorNumber As Long = 2

  ExcelColorSaved = ActiveWorkbook.Colors(ColorNumber)

  R_Color = (Dbl_ColorBefore Mod 256)
  G_Color = ((Dbl_ColorBefore \ 256) Mod 256)
  B_Color = (((Dbl_ColorBefore \ 256) \ 256) Mod 256)

  If Application.Dialogs(xlDialogEditColor).Show(ColorNumber, R_Color, G_Color, B_Color) = True Then
     PickColor = ActiveWorkbook.Colors(ColorNumber)
  Else
     PickColor = Dbl_ColorBefore
  End If
    
  ActiveWorkbook.Colors(ColorNumber) = ExcelColorSaved

End Function

 

 

RGB Color Codes Chart 🎨

RGB Color Codes Chart RGB color picker | RGB color codes chart | RGB color space | RGB color format and calculation | RGB color table RGB color picker RGB color codes chart Hover with cursor on color to get the hex and decimal color codes below: RGB color

www.rapidtables.com

 

LIST

'매크로 > 모듈(Module)' 카테고리의 다른 글

Import the file to the sheet  (0) 2022.10.23
Export Range to File...  (0) 2022.10.23
Free VBA Addin ImageMSO Gallery  (0) 2022.10.22
Module Export and Import  (0) 2022.10.22
Insert Event Modules into Worksheet  (0) 2022.10.22