Hi guys
Thank you in advance for taking the time to read this post and trying to help.
Below is a snippet of the code (... indicates code omitted for simplification) where I am trying to annotate a chart after it is generated.
The code sometimes behaves like the Text assignment (last line of code below) is simply a comment and doesn't place the strings into the textbox; when that happens I place a code execution BREAK on the assignment and "Step-Into" the line and it works. Other times it works just fine. Hoping for some possible explanations as to Why?
Thanks again for all your help
Thank you in advance for taking the time to read this post and trying to help.
Below is a snippet of the code (... indicates code omitted for simplification) where I am trying to annotate a chart after it is generated.
The code sometimes behaves like the Text assignment (last line of code below) is simply a comment and doesn't place the strings into the textbox; when that happens I place a code execution BREAK on the assignment and "Step-Into" the line and it works. Other times it works just fine. Hoping for some possible explanations as to Why?
Code:
...
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xl3DPieExploded
With ActiveChart.Parent
.Height = 600 ' resize
.Width = 700 ' resize
.Top = 5 ' reposition
.Left = 320 ' reposition
End With
' set range for graph
If lastRow > 8 Then
Source = "Graph!" & Range("A2:B10").Address
Else
Source = "Graph!" & Range("A2:B8").Address
End If
ActiveChart.SetSourceData Source:=Range(Source)
ActiveChart.HasTitle = False
ActiveChart.HasTitle = True
ActiveChart.ChartTitle.Text = "Competitive Range of Hourly Rates"
ActiveChart.ApplyLayout (1)
ActiveWindow.Visible = True
Range("A2").Select
ActiveSheet.ChartObjects(1).Activate
ActiveChart.Shapes.AddTextbox(msoTextOrientationHorizontal, 10, 20.5, 198, 167.25).Select
Sheets(wsName).Select
With ws
If lastRow > 8 Then
EvaluateString = "Hourly Rate Low Pts Mid Pts " & Chr(10) & _
.Cells(2, "A").Value & " " & .Cells(2, "E").Value & " " & .Cells(2, "F").Value & Chr(10) & _
.Cells(3, "A").Value & " " & .Cells(3, "E").Value & " " & .Cells(3, "F").Value & Chr(10) & _
.Cells(4, "A").Value & " " & .Cells(4, "E").Value & " " & .Cells(4, "F").Value & Chr(10) & _
.Cells(5, "A").Value & " " & .Cells(5, "E").Value & " " & .Cells(5, "F").Value & Chr(10) & _
.Cells(6, "A").Value & " " & .Cells(6, "E").Value & " " & .Cells(6, "F").Value & Chr(10) & _
.Cells(7, "A").Value & " " & .Cells(7, "E").Value & " " & .Cells(7, "F").Value & Chr(10) & _
.Cells(8, "A").Value & " " & .Cells(8, "E").Value & " " & .Cells(8, "F").Value & Chr(10)
EvaluateString2 = "" & _
.Cells(9, "A").Value & " " & .Cells(9, "E").Value & " " & .Cells(9, "F").Value & Chr(10) & _
.Cells(10, "A").Value & " " & .Cells(10, "E").Value & " " & .Cells(10, "F").Value & Chr(10)
Else
EvaluateString = "Hourly Rate Low Pts Mid Pts " & Chr(10) & _
.Cells(2, "A").Value & " " & .Cells(2, "E").Value & " " & .Cells(2, "F").Value & Chr(10) & _
.Cells(3, "A").Value & " " & .Cells(3, "E").Value & " " & .Cells(3, "F").Value & Chr(10) & _
.Cells(4, "A").Value & " " & .Cells(4, "E").Value & " " & .Cells(4, "F").Value & Chr(10) & _
.Cells(5, "A").Value & " " & .Cells(5, "E").Value & " " & .Cells(5, "F").Value & Chr(10) & _
.Cells(6, "A").Value & " " & .Cells(6, "E").Value & " " & .Cells(6, "F").Value & Chr(10) & _
.Cells(7, "A").Value & " " & .Cells(7, "E").Value & " " & .Cells(7, "F").Value & Chr(10) & _
.Cells(8, "A").Value & " " & .Cells(8, "E").Value & " " & .Cells(8, "F").Value & Chr(10)
EvaluateString2 = ""
End If
End With
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = EvaluateString & EvaluateString2
'''
Thanks again for all your help