Vba Naming a Created Line Connector

ericmax79

New Member
Joined
Dec 13, 2013
Messages
37
[FONT=Verdana, serif]HelloMy Name IS Eric Nice To Meet you all .....[/FONT][FONT=Verdana, serif] [/FONT][FONT=Verdana, serif]

Ihave a simple Question .I would like to name a shape in excel uponits creation ...... I Can name the"line" in the macro....But I would like every other line created after its Name to be"numerated or given a unique identifier while keeping its parentname "Jimmy". I believe it has to do with a "eventHandler " but i am way to new to excel to determine exactly whati need ...........Please Help Someone ! code attached below.........
[/FONT]
[FONT=Verdana, serif] [/FONT][FONT=Verdana, serif]
Like"Jimmy1" "Jimmy2" etc
[/FONT]
[FONT=Verdana, serif] [/FONT][FONT=Verdana, serif]

[/FONT]
Code:
[/FONT][/COLOR][COLOR=#333333][FONT=Verdana, serif][SIZE=2]
SubNeave_Click()
ActiveSheet.Shapes.AddConnector(msoConnectorStraight,400, 150, 800,150).Select
Selection.ShapeRange.Line.BeginArrowheadLength =msoArrowheadShort
Selection.ShapeRange.Line.BeginArrowheadStyle =msoArrowheadStealth
Selection.ShapeRange.Line.BeginArrowheadWidth= msoArrowheadNarrow
Selection.ShapeRange.Line.EndArrowheadLength= msoArrowheadShort
Selection.ShapeRange.Line.EndArrowheadStyle =msoArrowheadStealth
Selection.ShapeRange.Line.EndArrowheadWidth =msoArrowheadNarrow
Selection.ShapeRange.Line.Weight =2.5
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0,255)
Selection.Name = "Jimmy"
End Sub[/SIZE][/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]
[FONT=Verdana, serif]Thankyou in advance Eric Maxfield [/FONT]
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Maybe something like this.
Change the 3 in For i = 1 To 3 to the number of lines you want.


Code:
Option Explicit

Sub NeaveClick()
Dim i As Long, j As Long
j = 0

For i = 1 To 3
 j = j
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 400, 150 + j, 800, 150 + j).Select
Selection.ShapeRange.Line.BeginArrowheadLength = msoArrowheadShort
Selection.ShapeRange.Line.BeginArrowheadStyle = msoArrowheadStealth
Selection.ShapeRange.Line.BeginArrowheadWidth = msoArrowheadNarrow
Selection.ShapeRange.Line.EndArrowheadLength = msoArrowheadShort
Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadStealth
Selection.ShapeRange.Line.EndArrowheadWidth = msoArrowheadNarrow
Selection.ShapeRange.Line.Weight = 2.5
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 255)
Selection.Name = "Jimmy" & i
j = j + 10
Next
End Sub

Regards,
Howard
 
Upvote 0
Solved ! Thank you so Much Friend .Life Saver ..That would Have took me all day .I'm Just A Rookies tytytyty
 
Upvote 0
You're welcome, and thanks for the feed back.

Regards,
Howard



Hey Howard . It works Awesome . But How Can I draw 1 line at a time at runtime . And then it would number that line from 1-10 . Your code builds 3 lines and number thems . Which Is cool . But i would like to Build one line at a time and Then number it . When i Use your method at runtime . It of course numbers the line. But Does not Number it upon Creation . It makes 3 lines all called "jimmy1" when i do it manually . At Runtime .....Thank you very Much For your Help It is much Appreciated .

Eric MAxfield
 
Upvote 0
Does this do it, I may not understand your request.

Set Cell A1 to the number you want to start numbering the lines.
Each time you run the code it should produce the line name with the next number in sequence.


Code:
Option Explicit

Sub NeaveClick()
Dim i As Long
i = Range("A1")

ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 400, 150, 800, 150).Select
Selection.ShapeRange.Line.BeginArrowheadLength = msoArrowheadShort
Selection.ShapeRange.Line.BeginArrowheadStyle = msoArrowheadStealth
Selection.ShapeRange.Line.BeginArrowheadWidth = msoArrowheadNarrow
Selection.ShapeRange.Line.EndArrowheadLength = msoArrowheadShort
Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadStealth
Selection.ShapeRange.Line.EndArrowheadWidth = msoArrowheadNarrow
Selection.ShapeRange.Line.Weight = 2.5
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 255)
Selection.Name = "Jimmy" & i
Range("A1").Value = Range("A1").Value + 1

End Sub

Regards,
Howard
 
Upvote 0
Absolutely It works ! Thank You Howard .Your The Man :) :p









Does this do it, I may not understand your request.

Set Cell A1 to the number you want to start numbering the lines.
Each time you run the code it should produce the line name with the next number in sequence.


Code:
Option Explicit

Sub NeaveClick()
Dim i As Long
i = Range("A1")

ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 400, 150, 800, 150).Select
Selection.ShapeRange.Line.BeginArrowheadLength = msoArrowheadShort
Selection.ShapeRange.Line.BeginArrowheadStyle = msoArrowheadStealth
Selection.ShapeRange.Line.BeginArrowheadWidth = msoArrowheadNarrow
Selection.ShapeRange.Line.EndArrowheadLength = msoArrowheadShort
Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadStealth
Selection.ShapeRange.Line.EndArrowheadWidth = msoArrowheadNarrow
Selection.ShapeRange.Line.Weight = 2.5
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 255)
Selection.Name = "Jimmy" & i
Range("A1").Value = Range("A1").Value + 1

End Sub

Regards,
Howard
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,704
Members
449,118
Latest member
MichealRed

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