资源描述:
《excelvba_批量自动制图表实例集锦》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、完美.格式.编辑1,自动生成图表‘http://club.excelhome.net/thread-1058346-1-1.html‘统计报告0925a.xls‘2013-9-25Sublqxs()DimArr,ks,js,nm1$,nm2$,dz1$,dz2$Dimdz$,dz3$,yy$,nm$Application.ScreenUpdating=FalseSheet3.ActivateArr=[a1].CurrentRegionks=3:js=UBound(Arr)-1nm=Sheet3.Nameyy=Left(nm,Len
2、(nm)-3)nm1="图表6"nm2="图表4"dz="A2:B"&js&",D2:E"&jsActiveSheet.ChartObjects(nm1).ActivateWithActiveChart.SetSourceDataSource:=Sheets(nm).Range(dz),PlotBy:=xlColumns.SeriesCollection(1).Selectdz1="R3C2:R"&js&"C2".SeriesCollection(1).Values="='"&nm&"'!"&dz1dz2="R3C4:R"&js&
3、"C4".SeriesCollection(2).Values="='"&nm&"'!"&dz2dz3="R3C5:R"&js&"C5".SeriesCollection(3).Values="='"&nm&"'!"&dz3.ChartTitle.SelectSelection.Characters.Text=yy&"月份合格率"EndWithActiveSheet.ChartObjects(nm2).ActivateWithActiveChart.ChartArea.Selectdz="H2:T2,H"&js+1&":T"&js
4、+1.SetSourceDataSource:=Sheets(nm).Range(dz),PlotBy:=_xlRowsdz2="R"&js+1&"C8:R"&js+1&"C20".SeriesCollection(1).Values="='"&nm&"'!"&dz2.ChartTitle.SelectSelection.Characters.Text=yy&"月份不良趋势统计"EndWithRange("A"&ks).Select专业.资料.整理完美.格式.编辑Application.ScreenUpdating=TrueMsg
5、Box"OK"EndSub专业.资料.整理完美.格式.编辑2,批量插入图表‘2010-9-27‘批量绘图表.xlsSubChartsAdd()DimmyChartAsChartObjectDimiAsIntegerDimRAsIntegerDimmAsIntegerR=Sheet1.Range("A65536").End(xlUp).Row-1m=Abs(Int(-(R/4)))Sheet2.ChartObjects.DeleteFori=1ToRSetmyChart=Sheet2.ChartObjects.Add_(Left:=
6、(((i-1)Modm)+1)*350-320,_Top:=((i-1)m+1)*220-210,_Width:=330,Height:=210)WithmyChart.Chart.ChartType=xlColumnClustered.SetSourceDataSource:=Sheet1.Range("B2:M2").Offset(i-1),_PlotBy:=xlRowsWith.SeriesCollection(1).XValues=Sheet1.Range("B1:M1").Name=Sheet1.Range("A2")
7、.Offset(i-1).ApplyDataLabelsAutoText:=True,ShowValue:=True.DataLabels.Font.Size=10EndWith专业.资料.整理完美.格式.编辑.HasLegend=FalseWith.ChartTitle.Left=5.Top=1.Font.Size=14.Font.Name="华文行楷"EndWithWith.PlotArea.Interior.ColorIndex=2.PatternColorIndex=1.Pattern=xlSolidEndWith.Axe
8、s(xlCategory).TickLabels.Font.Size=10.Axes(xlValue).TickLabels.Font.Size=10EndWithNextSheet2.SelectSetmyChart=NothingEndSub3