Input box and carriage return for chart title

J

Joel Mills

I'm using excel 2000. Can someone help me revise the following code to
allow for a carriage return by the user while inputting text for the chart
title. Or is there an easier method that allows a user to enter a title
into a chart besides a message box?

Joel Mills

Sub ChartHeader()
'
ActiveSheet.ChartObjects("Curve Chart").Activate
ActiveChart.ChartArea.Select
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = InputBox("Enter the Chart Title Here"
& vbCr & _
"after creating the title select" & vbCr & " where you want to start a
new line |" _
& vbCr & "and hit enter to force a to a new line.")
End With

End Sub
 
J

Jim Cone

Joel,

I don't believe there is a way to force a carriage return
during text entry in an Input box.
However, you can put one in after the entry is complete.
Note: the following code will only force one additional line...

'-----------------------------
Sub SplitInputBoxText()
Dim strInput As String
Dim lngDot As Long

strInput = InputBox("Enter the Chart Title below." & vbCr & _
"A new line will automatically be started after a period (dot).", _
"Enter Chart Title", "Chart Title")
If Len(strInput) = 0 Then
Exit Sub
Else
lngDot = InStr(1, strInput, ".", vbTextCompare)
If lngDot > 1 Then
strInput = Left$(strInput, lngDot) & vbCr & _
LTrim$(Right$(strInput, Len(strInput) - lngDot))
End If
End If

MsgBox strInput
End Sub
'--------------------

Regards,
Jim Cone
San Francisco, USA



I'm using excel 2000. Can someone help me revise the following code to
allow for a carriage return by the user while inputting text for the chart
title. Or is there an easier method that allows a user to enter a title
into a chart besides a message box?
Joel Mills

Sub ChartHeader()
ActiveSheet.ChartObjects("Curve Chart").Activate
ActiveChart.ChartArea.Select
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = InputBox("Enter the Chart Title Here"
& vbCr & _
"after creating the title select" & vbCr & " where you want to start a
new line |" _
& vbCr & "and hit enter to force a to a new line.")
End With
End Sub
 
J

Joel Mills

Jim, thanks for your reply. I think the users will just have to input a
carriage return into the Chart Title as they would if they created the chart
using chart wizard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top