Is there anyway to see what color (code) I’ve used for a border?

slam

Well-known Member
Joined
Sep 16, 2002
Messages
921
Office Version
  1. 365
  2. 2019
I now need to use the same color in some VB code.

Thanks
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
samples below....

Code:
Sub ColorSceme()
With ActiveCell.Interior
    Debug.Print "Interior: "; .Color, ColorCodeToRGB(.Color), .ColorIndex
End With
With ActiveCell.Borders(xlEdgeTop)
    Debug.Print "Top: "; .Color, ColorCodeToRGB(.Color), .ColorIndex
End With
With ActiveCell.Borders(xlEdgeBottom)
    Debug.Print "Bottom: "; .Color, ColorCodeToRGB(.Color), .ColorIndex
End With
With ActiveCell.Borders(xlEdgeLeft)
    Debug.Print "Left: "; .Color, ColorCodeToRGB(.Color), .ColorIndex
End With
With ActiveCell.Borders(xlEdgeRight)
    Debug.Print "Right: "; .Color, ColorCodeToRGB(.Color), .ColorIndex
End With
End Sub
Public Function ColorCodeToRGB(lColorCode As Long) As String
' [URL]http://www.buygold.net/v02n04/v02n04.html[/URL] [modified]
' 1996/01/16 Return the individual colors for lColorCode.
' 1996/07/15 Use Tip 171: Determining RGB Color Values, MSDN July 1996.
' Enter with:
'     lColorCode contains the color to be converted
'
' Return:
'     iRed    contains the red component
'     iGreen  the green component
'     iBlue   the blue component
'
    Dim lColor As Long
    lColor = lColorCode      'work long
    iRed = lColor Mod &H100  'get red component
    lColor = lColor \ &H100  'divide
    iGreen = lColor Mod &H100 'get green component
    lColor = lColor \ &H100  'divide
    iBlue = lColor Mod &H100 'get blue component
    ColorCodeToRGB = iRed & ", " & iGreen & ", " & iBlue
End Function
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top