ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Charts and Charting in Excel (https://www.excelbanter.com/charts-charting-excel/)
-   -   VBA for chart title issue (https://www.excelbanter.com/charts-charting-excel/136816-vba-chart-title-issue.html)

Barb Reinhardt

VBA for chart title issue
 
I have the following macro to modify a chart title if "mypattern" is changed.
I'm having one problem though. At the place where I have vbnewline in the
mypattern code, it appears that it's displaying 2 line breaks. How do I fix
this?

Thanks,
Barb Reinhardt

Public Sub SetChartTitle(WS As Worksheet, mypattern As String)
Dim objCht As ChartObject

mypattern = WS.Name & vbNewLine & "Division Target " & mypattern & " Days"
For Each objCht In WS.ChartObjects
With objCht
.Chart.ChartTitle.Text = mypattern
End With
Next objCht
End Sub


Andy Pope

VBA for chart title issue
 
Hi,

It would appear that both CarriageReturn and LineFeed both cause a new line
in the title.
Use either vbCR or vbLF instead of vbNewLine

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Barb Reinhardt" wrote in message
...
I have the following macro to modify a chart title if "mypattern" is
changed.
I'm having one problem though. At the place where I have vbnewline in the
mypattern code, it appears that it's displaying 2 line breaks. How do I
fix
this?

Thanks,
Barb Reinhardt

Public Sub SetChartTitle(WS As Worksheet, mypattern As String)
Dim objCht As ChartObject

mypattern = WS.Name & vbNewLine & "Division Target " & mypattern & " Days"
For Each objCht In WS.ChartObjects
With objCht
.Chart.ChartTitle.Text = mypattern
End With
Next objCht
End Sub



Barb Reinhardt

VBA for chart title issue
 
Thanks, that did it!

"Andy Pope" wrote:

Hi,

It would appear that both CarriageReturn and LineFeed both cause a new line
in the title.
Use either vbCR or vbLF instead of vbNewLine

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Barb Reinhardt" wrote in message
...
I have the following macro to modify a chart title if "mypattern" is
changed.
I'm having one problem though. At the place where I have vbnewline in the
mypattern code, it appears that it's displaying 2 line breaks. How do I
fix
this?

Thanks,
Barb Reinhardt

Public Sub SetChartTitle(WS As Worksheet, mypattern As String)
Dim objCht As ChartObject

mypattern = WS.Name & vbNewLine & "Division Target " & mypattern & " Days"
For Each objCht In WS.ChartObjects
With objCht
.Chart.ChartTitle.Text = mypattern
End With
Next objCht
End Sub





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

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