format text string for SeriesCollection.Name property

  • Thread starter Thread starter Rajdeep
  • Start date Start date
R

Rajdeep

I have a plot in which I would like to rename a data series object using
VBA. I use the following code:

Public Sub ChangeSeriesCollectionName()

Dim textString As String

textString = " 104.0 "

ActiveChart.SeriesCollection(1).Name = textString

End Sub

In reality the text string is imported from a 10 character user comment
section in a data file. My problem is that when Excel renames the data
series, it drops the ".0" part simply to "104". This happens despite the use
of the VBA Format function in the form Format(textString."@@@@@@") or
Format(textString."000000") to force either the inclusion of a zero or to
use the text literally (preferred). In addition if I use something like
textString = "A 104.0 " then all the spaces/zeros are accepted without
the use of a Format function probably because it now treats textString as a
real string.

Is there any way to force Excel to accept the above string as is without any
interpretation?

Thanks.
 

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

Back
Top