我对VBA编程有问题。我想读一个标签的文本,它表示曲线的内插。我使用了这个代码:
ActiveChart.SeriesCollection(Numero_serie).Trendlines(1).DataLabel.Select
Selection.NumberFormat = "0.000000"
' estrae dall'etichetta di una interpolazione i coefficienti e li ricopia in celle scelte dall'utente
Dim s, x3, x2, x, c, R As Double
Dim i1, i2, i3, f1, f2, f3, ic, fc
s = ActiveChart.SeriesCollection(Numero_serie).Trendlines(1).DataLabel.Text
f4 = InStr(s, "x4")
x4 = Val(Replace(Mid(s, i4, f4 - i4), ",", "."))
Worksheets("Interpola").Range("B" & 6) = s代码可以工作,但它用B6编写的标签总是相同的,即使我将数字格式更改为"0.0000“。谢谢你的关注,安德里亚
发布于 2015-01-26 20:41:26
试试这个:
Dim ws As Worksheet
Dim ch As ChartObject
Dim s As String
Set ws = Worksheets("Interpola")
Set ch = ws.ChartObjects("Chart 1")
ch.Select
ActiveChart.SeriesCollection(Numero_serie).Trendlines(1).DataLabel.NumberFormat = "0.0000"
s = ActiveChart.SeriesCollection(Numero_serie).Trendlines(1).DataLabel.Text
ws.Range("B6").Value = s备注-将“图表1”更改为图表的名称。
当我将NumberFormat从"0.000000“更改为"0.0000”时,这对我起了作用。
发布于 2015-01-27 11:15:39
非常感谢,它很好用。我认为问题是:
ActiveChart.SeriesCollection(Numero_serie).Trendlines(1).DataLabel.NumberFormat = "0.0000"是不同的
thisActiveChart.SeriesCollection(Numero_serie).Trendlines(1).DataLabel.Select
Selection.NumberFormat="0.0000"我不知道为什么,但现在一切都很好。谢谢!
https://stackoverflow.com/questions/28154857
复制相似问题