【发布时间】:2016-09-30 03:43:40
【问题描述】:
问题:
您需要创建三个变量,如下所示:
“rangeData”:存储当前选中的范围。 "titleChart": 存储图表标题 "nameSheet" : 存放工作表名
您将使用InputBox 函数两次来获取图表的标题和工作表的名称,并使用为图表指定的标题和为工作表指定的名称。
到目前为止,我一直坚持将值从 InputBox 获取到新图表标题:
到目前为止我的代码:
Dim RangeData As Integer
Dim rng As Range
Dim ctInputbox As String
Dim CT As ChartTitle
Dim nsnInputbox As String
Dim nsn As Worksheet
'Change Data source to currentley selected cells
Set rng = Selection
'Add a chart onto the active sheet and select the chart
ActiveSheet.Shapes.AddChart.Select
'Chart type is Clustered Column chart
ActiveChart.ChartType = xlColumnClustered
'Assign a chart title:
'instead of using the content of cell H13 as the chart title, ask
'the user for the title of the chart and set the title
'Add user data to create a chart title
ctInputbox = InputBox("Please enter a chart title", "Chart Title Name")
ActiveChart.HasTitle = True
With ActiveChart.ChartObjects
Set CT = ctInputbox
End With
End Sub
【问题讨论】: