谁能教我如何在 CurrentRegion 属性中选择多个列,以便我可以基于它创建条形图
以下是我到目前为止的进展..但是它不起作用
Public Function FourthTable()
Dim Source As Workbook
Dim Search As Range
Dim CR As Range
SRT = "Service Request Tickets (IIT)"
Set Source = Workbooks.Open("C:\Users\HP\Desktop\test.xlsx")
Source.Worksheets("Sheet1").Activate
Set Search = ActiveSheet.Cells.Find(SRT)
Source.Worksheets("Sheet1").Range(Search.Address).Offset(2, 0).CurrentRegion.Activate
ActiveCell.CurrentRegion.Columns.Range("A:A,
C:C").Resize(ActiveCell.CurrentRegion.Rows.Count - 1).Select
ActiveSheet.Shapes.AddChart.Select
'ActiveChart.SetSourceData
Source:=ActiveWorkbook.Sheets(1).Range(Search.Address).Offset(2,
0).CurrentRegion.Resize(CR.Rows.Count - 1, CR.Columns.Count)
ActiveChart.ChartType = xl3DBarClustered
With ActiveChart
.Perspective = 0
.Elevation = 15
.Rotation = 20
.RightAngleAxes = True
End With
ActiveSheet.ChartObjects(1).Activate
ActiveSheet.ChartObjects(1).Cut
With Sheets("Sheet2")
.Select
.Range("A34").Select
End With
ActiveSheet.Paste
Source.Close SaveChanges:=True
End Function
我得到的错误信息是应用程序定义的或对象定义的错误
我要选择的列是 A 列和 C 列。我无法通过指示“A34”或“C34”等单元格的地址来选择列,因为表数据是使用程序工具生成的,因此是位置表数据的每次都不同
下图是我参考的表格数据