Previous in Forum: Wind Energy Software   Next in Forum: Centum CS 3000
Close
Close
Close
2 comments
Rate Comments: Nested
Power-User

Join Date: Feb 2011
Location: Shimurali, Westbengal,India
Posts: 119

VB Code to Change Picture (Straight Line) Color in Excel

03/04/2013 3:07 AM

In Excel 2007 I put a straight line(from picture) and it's color (initially) RED. When I click on the Line then it will change it's color from Red to Green. Please support me how I can write a code in VB to impliment it in excel?

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru

Join Date: Mar 2007
Location: by the beach in Florida
Posts: 33392
Good Answers: 1817
#1

Re: VB Code to Change Picture (Straight Line) Color in Excel

03/06/2013 10:30 AM
__________________
All living things seek to control their own destiny....this is the purpose of life
Register to Reply
Active Contributor

Join Date: Jul 2012
Location: South Africa
Posts: 13
Good Answers: 3
#2

Re: VB Code to Change Picture (Straight Line) Color in Excel

03/08/2013 3:13 PM

This should get you going:

(you need to assign the macro to the line)

Sub StraightConnector2_Click()
If ActiveSheet.Shapes("Straight Connector 2").Line.ForeColor.RGB = RGB(255, 0, 0) Then
ActiveSheet.Shapes("Straight Connector 2").Line.ForeColor.RGB = RGB(0, 255, 0)
Else
ActiveSheet.Shapes("Straight Connector 2").Line.ForeColor.RGB = RGB(255, 0, 0)
End If
Range("A1").Select
End Sub

__________________
Living is more than mere existence and breath
Register to Reply
Register to Reply 2 comments

Previous in Forum: Wind Energy Software   Next in Forum: Centum CS 3000

Advertisement