I was trying to avoid a lengthy post but this might help.
What I am trying to do:
- User selects a label in a chart that is embedded in a worksheet. For example, in a bar graph the label indicating tha value of the graph.
- A pop-up window appears asking the user to enter text that they want included on the label
- That text is then included with the value that is already there, as a superscript.
But the "Text" variable always returns "" (not Empty). So the end result then adds what the user enters, but deletes the originol label value.
This did work before I upgraded to the new version of Excel.
Note: The "number" variable at the bottom is created in a seperate Sub. That Sub is only used to obtain the number that Excel puts on all charts created in a worksheet.
I hope this is what you need.
Thanks again
Code
Private Sub EmbChart_Select(ByVal ElementID As Long, _
ByVal Arg1 As Long, ByVal Arg2 As Long)
If Arg2 > 0 Then
'Obtain superscript text (user inputed)
sScript = InputBox("Type in the superscript exactly how you want it", _
"Superscript", "Enter superscript here")
If sScript <> "" Then
Length1 = Len(sScript)
'Enter the superscript
ActiveChart.SeriesCollection(Arg1).Points(Arg2).DataLabel.Select
Text = Selection.Characters.Text
Length2 = Len(Selection.Characters.Text)
Selection.Characters.Text = Text & sScript
Selection.AutoScaleFont = False
Selection.AutoScaleFont = False
With Selection.Characters(Start:=Length2 + 1, Length:=Length1).Font
.Superscript = True
End With
ActiveWindow.Visible = False
ActiveSheet.ChartObjects(Number).Activate
End If
End If