资源描述:
《excel-vba-批量自动制图表实例集锦》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
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(nm)-3)nm1="图表6"nm2="图表4"dz
2、="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&"C4".SeriesCollection(2).Values="='"&nm&"'!"&d
3、z2dz3="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+1.SetSourceDataSource:=Sheets(nm).Range(dz),PlotBy:=_xlRowsdz2="
4、R"&js+1&"C8:R"&js+1&"C20".SeriesCollection(1).Values="='"&nm&"'!"&dz2.ChartTitle.SelectSelection.Characters.Text=yy&"月份不良趋势统计"EndWithRange("A"&ks).SelectApplication.ScreenUpdating=TrueMsgBox"OK"EndSub2,批量插入图表‘2010-9-27‘批量绘图表.xlsSubChartsAdd()DimmyChartAsChartObjectDimiAsIntegerDimRAsInt
5、egerDimmAsIntegerR=Sheet1.Range("A65536").End(xlUp).Row-1m=Abs(Int(-(R/4)))Sheet2.ChartObjects.DeleteFori=1ToRSetmyChart=Sheet2.ChartObjects.Add_(Left:=(((i-1)Modm)+1)*350-320,_Top:=((i-1)m+1)*220-210,_Width:=330,Height:=210)WithmyChart.Chart.ChartType=xlColumnClustered.SetSourceDataSo
6、urce:=Sheet1.Range("B2:M2").Offset(i-1),_PlotBy:=xlRowsWith.SeriesCollection(1).XValues=Sheet1.Range("B1:M1").Name=Sheet1.Range("A2").Offset(i-1).ApplyDataLabelsAutoText:=True,ShowValue:=True.DataLabels.Font.Size=10EndWith.HasLegend=FalseWith.ChartTitle.Left=5.Top=1.Font.Size=14.Font.Na
7、me="华文行楷"EndWithWith.PlotArea.Interior.ColorIndex=2.PatternColorIndex=1.Pattern=xlSolidEndWith.Axes(xlCategory).TickLabels.Font.Size=10.Axes(xlValue).TickLabels.Font.Size=10EndWithNextSheet2.SelectSetmyChart=NothingEndSub3,批量插入图表‘2013-9-30‘http://club.excelhome.net/forum.php?mo