ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Input box and carriage return for chart title (https://www.excelbanter.com/excel-programming/332840-input-box-carriage-return-chart-title.html)

Joel Mills

Input box and carriage return for chart title
 
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



Jim Cone

Input box and carriage return for chart title
 
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



"Joel Mills" wrote in message
...
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

Joel Mills

Input box and carriage return for chart title
 
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.


"Jim Cone" wrote in message
...
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



"Joel Mills" wrote in message
...
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





All times are GMT +1. The time now is 04:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com