excel点击窗口中按钮,能否实现显示图表窗口?
发布网友
发布时间:2022-04-24 05:13
我来回答
共1个回答
热心网友
时间:2023-10-31 01:39
我之前给你的如下代码中,Output中的"Sheet2"可以改为Sheet1,这样图表为改为在Sheet1中显示。
Private Sub 图表_Click()
Dim Output As Range
Set Output = Sheets("Sheet2").Range("A1")
If Output.Worksheet.Shapes.Count > 0 Then
Output.Worksheet.Shapes.Item(0).Delete
End If
Output.Worksheet.Activate
Output.Worksheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range(Output, Output.End(xlDown).Offset(0, 1))
ActiveChart.ChartType = xlLineMarkers
End Sub
热心网友
时间:2023-10-31 01:39
我之前给你的如下代码中,Output中的"Sheet2"可以改为Sheet1,这样图表为改为在Sheet1中显示。
Private Sub 图表_Click()
Dim Output As Range
Set Output = Sheets("Sheet2").Range("A1")
If Output.Worksheet.Shapes.Count > 0 Then
Output.Worksheet.Shapes.Item(0).Delete
End If
Output.Worksheet.Activate
Output.Worksheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range(Output, Output.End(xlDown).Offset(0, 1))
ActiveChart.ChartType = xlLineMarkers
End Sub
热心网友
时间:2023-10-31 01:39
我之前给你的如下代码中,Output中的"Sheet2"可以改为Sheet1,这样图表为改为在Sheet1中显示。
Private Sub 图表_Click()
Dim Output As Range
Set Output = Sheets("Sheet2").Range("A1")
If Output.Worksheet.Shapes.Count > 0 Then
Output.Worksheet.Shapes.Item(0).Delete
End If
Output.Worksheet.Activate
Output.Worksheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range(Output, Output.End(xlDown).Offset(0, 1))
ActiveChart.ChartType = xlLineMarkers
End Sub