ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change the line color based on the value selected in combo box (https://www.excelbanter.com/excel-programming/366185-change-line-color-based-value-selected-combo-box.html)

Avinash

Change the line color based on the value selected in combo box
 
Hi,
I am using the VBA. I want to change the line color based on the value
selected in the combo box. Can anybody help on this.

Thanks,
Avinash Sharma

crazybass2

Change the line color based on the value selected in combo box
 
Private Sub ComboBox1_Change()
Shapes(yourlinename).Line.ForeColor.SchemeColor = ComboBox1.Value
End Sub

Replace yourlinename with the name of the line you want to change.
Likewise, if your combobox is not Combobox1 you must change this reference as
well. The combobox should contain the SchemeColor numbers that correspond to
the color you want. For instance,

Color SchemeColor Number
White 1
Red 2
Light Green3
Blue 4
Yellow 5
Pink 6
Cyan 7
Black 8
Green 17
Light Gray 22
Gray 23
Orange 53


You could also list the names of the colors in the combobox and reference
the color number in code based on the selection.



"Avinash" wrote:

Hi,
I am using the VBA. I want to change the line color based on the value
selected in the combo box. Can anybody help on this.

Thanks,
Avinash Sharma



All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com