I am looking at writing a little bit of VBA code that will change displayed worksheet to the previous or next sheet in the order of the tabs.
I found this stackoverflow question which talks about adding an arrow, but its more like a leader arrow (red in the picture).
I want to add the LEFT or RIGHT arrow from the Insert ribbon -> illustrations section -> Shapes drop down:
The snipit of code I am using is:
Dim l As Long
Dim t As Long
l = Range("O3").Left
t = Range("Q3").Top
Item_Estimate_Sheet.Shapes.AddConnector(msoConnectorStraight, t + 89.25, l + 89.25, l, t).Select
With Selection
With .ShapeRange.Line
.EndArrowheadStyle = msoArrowheadOpen
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
.Weight = 1.5
End With
End With
What I am hoping to add is something that looks like the following which I added manually:
Part B
Avoiding use of select. I hear on here time and time again that select is to be avoided and its not required. I tried removing select and when I did this, it caused an error. A .something seems to be required at the the end of the add shape line. Is there a better way to do this?
Part C: Is there a way to get the dimensions/ properties of the shape you inserted other than recording a macro at the time of insertion? (and damn why did I not remember to record a macro)
UPDATE:
so I recorded a macro and edited my code as follow:
Item_Estimate_Sheet.Shapes.AddShape(msoShapeRightArrow, 859.5, 35.25, 25.5, 19.5).Select
With Selection
With .ShapeRange.Line
.Name = "NEXT"
.Top = Range("S3").Top
.Left = Range("S3").Left
.Width = Range("Q3").Width * 2
.Height = Range("Q3").Height * 2
End With
End With
when I got rid of the select as follows it threw an error..something about not acceptable method:
With Item_Estimate_Sheet.Shapes.AddShape(msoShapeRightArrow, 859.5, 35.25, 25.5, 19.5)
With .ShapeRange.Line
.Name = "NEXT"
.Top = Range("S3").Top
.Left = Range("S3").Left
.Width = Range("Q3").Width * 2
.Height = Range("Q3").Height * 2
End With
End With