您將需要創建三個變量如下:
「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