我需要在excel中为50张不同的纸张制作相同的图表。我想这很容易用一些简单的VB知识(我不会......)。
我尝试使用宏制作图表。问题是图表在第9行和第16行中继续引用单个工作表/相同的来源(例如:ActiveChart.SetSourceData来源:=范围("' 2ok'!$ v:$ X& #34;))而不是使用50张纸中的每一张数据..
如果有人能帮助我,那将是甜蜜的。请记住,我的水平非常基本......
谢谢你们。
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+b
'
Columns("V:X").Select
ActiveSheet.Shapes.AddChart2(227, xlLine).Select
ActiveChart.SetSourceData Source:=Range("'2ok'!$V:$X")
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MaximumScale = 15000
ActiveChart.Axes(xlValue).MinimumScale = 0
ActiveChart.PlotArea.Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveChart.FullSeriesCollection(1).XValues = "='2ok'!$B:$B"
ActiveChart.ChartTitle.Select
ActiveChart.ChartTitle.Text = "Oil, Water & Gas Rates"
Selection.Format.TextFrame2.TextRange.Characters.Text = _
"Oil, Water & Gas Rates"
With Selection.Format.TextFrame2.TextRange.Characters(1, 22).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 12).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 14
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Spacing = 0
.Strike = msoNoStrike
End With
With Selection.Format.TextFrame2.TextRange.Characters(13, 10).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 14
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Spacing = 0
.Strike = msoNoStrike
End With
End Sub