View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rajdeep Rajdeep is offline
external usenet poster
 
Posts: 1
Default format text string for SeriesCollection.Name property

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.