|
5学分
Dim rng As Range
Dim STR As String
STR = InputBox("请输入最后一列的英文标识如M,G等")
Set rng = Range("A3:" & STR & "7")
MsgBox (rng.Address)
rng.Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
MsgBox (rng.Address)
ActiveChart.SetSourceData Source:=Range("Sheet1!$A$3:" & rng.Address)
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(3).Select
ActiveChart.SeriesCollection(3).ChartType = xlLineStacked100
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(4).Select
ActiveChart.SeriesCollection(3).Select
ActiveChart.SeriesCollection(3).AxisGroup = 2
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(3).Select
ActiveChart.SeriesCollection(4).ChartType = xlLine
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(3).Select
ActiveChart.SeriesCollection(4).Select
ActiveChart.SeriesCollection(4).AxisGroup = 2
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(4).Select
ActiveChart.SeriesCollection(4).ApplyDataLabels
ActiveChart.SeriesCollection(4).Points(8).Select
ActiveChart.SeriesCollection(4).Points(7).Select
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Points(7).Select
ActiveChart.SeriesCollection(1).Points(7).ApplyDataLabels
ActiveChart.SeriesCollection(3).Select
ActiveChart.SeriesCollection(3).ApplyDataLabels
Range("N36").Select
End Sub
我把 Set rng = Range("A3:" & STR & "7") 写成range(cells(3,1),cells(7,cloumns.count).end(xltoleft)不行,没把法才用了INPUTBOX,是什么原因呢?
本帖最后由 sgxb123431380 于 2013-10-9 08:48 编辑
Dim rng As Range
Dim STR As String
Set rng = Range(Cells(3, 1), Cells(7, Columns.Count).End(xlToLeft))
MsgBox (rng.Address)
rng.Select
ActiveSheet.Shapes.AddChart.Select
With ActiveChart
.ChartType = xlColumnClustered
MsgBox (rng.Address)
.SetSourceData Source:=Range("Sheet1!$A$3:" & rng.Address)
.SeriesCollection(3).ChartType = xlLineStacked100
.SeriesCollection(3).AxisGroup = 2
.SeriesCollection(4).ChartType = xlLine
.SeriesCollection(4).AxisGroup = 2
.SeriesCollection(4).ApplyDataLabels
.SeriesCollection(1).Points(7).ApplyDataLabels
.SeriesCollection(3).ApplyDataLabels
End With
Range("N36").Select
|
|