Hi there,
I'm looking to add a text box just below a shape. The textbox would be populated with the string found in cell c5.
The code i have for generating the shape is as follows;
and the spreadsheet layout is as follows ;
I'm not certain how to change this code to have a text box generated at the same time as the shape.
Regards,
John
I'm looking to add a text box just below a shape. The textbox would be populated with the string found in cell c5.
The code i have for generating the shape is as follows;
VBA Code:
Sub DANS()
Dim ws As Worksheet
Dim Start_Diamond As Shape
Dim End_Diamond As Shape
Dim conn As Shape
Dim Start_Range As Range
Dim End_Range As Range
Dim Start_Pos As Single
Dim End_Pos As Single
' Dim Caption As TextBox
On Error GoTo errorHandler
'set reference to a worksheet
Set ws = ActiveSheet
''''''''''''''''''''''''''''''''''''Task 1'''''''''''''''''''''''''''''''''''''''
'find start and end ranges
With Application
Set Start_Range = .Index(ws.Range("F5:BM5"), .Match(Format(ws.Range("D5").Value, "mmm"), ws.Range("F4:BM4"), 0))
Set End_Range = .Index(ws.Range("F5:BM5"), .Match(Format(ws.Range("E5").Value, "mmm"), ws.Range("F4:BM4"), 0))
End With
'find start position
With Start_Range
Start_Pos = .Left + (.Width / 2) - (8.5 / 2)
End With
'find end position
With End_Range
End_Pos = .Left + (.Width / 2) - (8.5 / 2)
End With
'add Start Diamond
Set Start_Diamond = ws.Shapes.AddShape(msoShapeDiamond, Start_Pos, Start_Range.Top + 2, 8.5, 9.6)
'add End Diamond
Set End_Diamond = ws.Shapes.AddShape(msoShapeDiamond, End_Pos, End_Range.Top + 2, 8.5, 9.6)
'Set the connector link
Set conn = ws.Shapes.AddConnector(msoConnectorStraight, 15, 150, 15, 150)
conn.ConnectorFormat.BeginConnect Start_Diamond, 1
conn.ConnectorFormat.EndConnect End_Diamond, 1
conn.RerouteConnections
exitHandler:
Exit Sub
errorHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Error"
Resume exitHandler
End Sub
and the spreadsheet layout is as follows ;
I'm not certain how to change this code to have a text box generated at the same time as the shape.
Regards,
John