我有一个 excel 文件,其中有多张标签为 HI12981001.asvp、HI19281002.asvp、HI19281003.asvp 等。
每张纸中有 2 列,没有标题。我正在使用下面的宏来创建每张工作表中这两列数据的散点图。问题是我必须手动更改每张纸的系列名称。
我正在寻求帮助来构建这个宏,以便我可以让 excel 查看一个列表(即 HI12981001.asvp、HI19281002.asvp、HI19281003.asvp .. 并在主图表中为每个工作表或简单创建一个数据系列浏览整本书并创建一个系列名称与工作表名称相同的图表。
这是前三张纸的宏
Sub zx()
Dim wb As Workbook
Dim sh As Worksheet
Dim Chrt As Chart
Dim Srs As Series
Set wb = ActiveWorkbook
Set Chrt = wb.Charts.Add(After:=wb.Worksheets(wb.Worksheets.Count))
Chrt.ChartType = xlXYScatterSmoothNoMarkers
Chrt.Name = "SVP Profiles"
Set Srs = Chrt.SeriesCollection.NewSeries
Srs.Name = "HI12981001.asvp"
Set sh = wb.Sheets("HI12981001.asvp")
Srs.XValues = "=" & sh.Name & "!" & sh.UsedRange.Columns(2).Address
Srs.Values = "=" & sh.Name & "!" & sh.UsedRange.Columns(1).Address
Set Srs = Chrt.SeriesCollection.NewSeries
Srs.Name = "HI12981002.asvp"
Set sh = wb.Sheets("HI12981002.asvp")
Srs.XValues = "=" & sh.Name & "!" & sh.UsedRange.Columns(2).Address
Srs.Values = "=" & sh.Name & "!" & sh.UsedRange.Columns(1).Address
Set Srs = Chrt.SeriesCollection.NewSeries
Srs.Name = "HI12981003.asvp"
Set sh = wb.Sheets("HI12981003.asvp")
Srs.XValues = "=" & sh.Name & "!" & sh.UsedRange.Columns(2).Address
Srs.Values = "=" & sh.Name & "!" & sh.UsedRange.Columns(1).Address
End Sub
谢谢