Hi All,
this is a most excellent forum with a wealth of information and a wonderful user base! I have learned a lot from this forum, and see many thoughtful answers. I have a macro which I need help with, I'm attempting to display a list of RGB codes to the recent colors section within excel via a VBA macro.
The current syntax is such:
Sub LoadRecentColors()
'PURPOSE: Use A List Of RGB Codes To Load Colors Into Recent Colors Section of Color Palette
Dim ColorList As Variant
Dim CurrentFill As Variant
'Array List of RGB Color Codes to Add To Recent Colors Section (Max 10)
ColorList = Array("198, 224, 180", "255, 255, 204", "230, 184, 183", "184, 204, 228", "54, 96, 146")
'Store ActiveCell's Fill Color (if applicable)
If ActiveCell.Interior.ColorIndex <> xlNone Then CurrentFill = ActiveCell.Interior.Color
'Optimize Code
Application.ScreenUpdating = False
'Loop Through List Of RGB Codes And Add To Recent Colors
For x = LBound(ColorList) To UBound(ColorList)
ActiveCell.Interior.Color = RGB(Left(ColorList(x), 3), Mid(ColorList(x), 5, 3), Right(ColorList(x), 3))
DoEvents
SendKeys "%hhm~"
DoEvents
Next x
'Return ActiveCell Original Fill Color
If CurrentFill = Empty Then
ActiveCell.Interior.ColorIndex = xlNone
Else
ActiveCell.Interior.Color = currentColor
End If
End Sub
I am having difficulties understanding the LBound to Ubound list, everytime I run the macro or try to edit this portion of the macro, I don't have success.
Would one of you VBA guru's be able to help?
Thanks,
MI
this is a most excellent forum with a wealth of information and a wonderful user base! I have learned a lot from this forum, and see many thoughtful answers. I have a macro which I need help with, I'm attempting to display a list of RGB codes to the recent colors section within excel via a VBA macro.
The current syntax is such:
Sub LoadRecentColors()
'PURPOSE: Use A List Of RGB Codes To Load Colors Into Recent Colors Section of Color Palette
Dim ColorList As Variant
Dim CurrentFill As Variant
'Array List of RGB Color Codes to Add To Recent Colors Section (Max 10)
ColorList = Array("198, 224, 180", "255, 255, 204", "230, 184, 183", "184, 204, 228", "54, 96, 146")
'Store ActiveCell's Fill Color (if applicable)
If ActiveCell.Interior.ColorIndex <> xlNone Then CurrentFill = ActiveCell.Interior.Color
'Optimize Code
Application.ScreenUpdating = False
'Loop Through List Of RGB Codes And Add To Recent Colors
For x = LBound(ColorList) To UBound(ColorList)
ActiveCell.Interior.Color = RGB(Left(ColorList(x), 3), Mid(ColorList(x), 5, 3), Right(ColorList(x), 3))
DoEvents
SendKeys "%hhm~"
DoEvents
Next x
'Return ActiveCell Original Fill Color
If CurrentFill = Empty Then
ActiveCell.Interior.ColorIndex = xlNone
Else
ActiveCell.Interior.Color = currentColor
End If
End Sub
I am having difficulties understanding the LBound to Ubound list, everytime I run the macro or try to edit this portion of the macro, I don't have success.
Would one of you VBA guru's be able to help?
Thanks,
MI