伟哉圣母峰电影:excel中用VBA批量生成图表
来源:百度文库 编辑:偶看新闻 时间:2024/05/03 09:13:31
Sub 图表批量生成()
For r = 1 To 100
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A" & r & ":E" & r)
'ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1" '删除本句前的'可将各个图表作为对象插入sheet1中,否则各图表将单独作为chart表插入工作簿。
Next
End Sub
===================
Sub 图表批量生成()
xx = 0
yy = 0
For r = 4 To 57 '以每位学生生成一个图表,循环产生全班每位学生的曲线图
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("一班全图").Range("A" & r & ":U" & r), PlotBy _
:=xlRows '源数据系列产生于行
ActiveChart.Location Where:=xlLocationAsObject,Name:="一班全图" '所有图表插入同一工作表中
With ActiveChart.Axes(xlValue) '设置图表属性 如:刻度和线型
.MinimumScaleIsAuto = True
.MaximumScale = 60
.MinorUnit = 1
.MajorUnit = 5
.Crosses = xlAutomatic
.ReversePlotOrder = True
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.Legend.Select
Selection.Delete
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 3
.Weight = xlMedium
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = 5
.MarkerStyle = xlCircle
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With '图表属性设置结束
Set myDocument = ActiveSheet
For Each S In myDocument.ChartObjects
'MsgBox (S.Name)
S.Activate
ActiveChart.ChartArea.Select '设置图表(即外框)大小及在工作表中的位置
S.Top = yy * 136
S.Left = xx * 274
S.Height = 132
S.Width = 270
ActiveChart.PlotArea.Select '设置绘图区大小及相对于外框的位置
Selection.Top = 9
Selection.Height = 132
Selection.Left = 0
Selection.Width = 270
xx = xx + 1 '设置计数器,让图表每三个排一行
If xx >= 3 Then
xx = 0
yy = yy + 1
End If
Next S
Next r
End Sub
==================================
ActiveChart.ChartArea.Select
Sub 改变图表尺寸()
Set myDocument = ActiveSheet
For Each S In myDocument.ChartObjects
'MsgBox (S.Name)
S.Activate
ActiveChart.ChartArea.Select '这部分是图表区的尺寸代码
S.Width = 200
S.Height = 200
ActiveChart.PlotArea.Select '这部分是绘图区的尺寸代码
Selection.Width = 191
Selection.Top = 9
Selection.Height = 185
Next S
End Sub=================
清除图表可以用这个:
Sub test()
For Each r In Sheets("一班全图").ChartObjects
r.Delete
Next
End Sub
=========================
For r = 1 To 100
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A" & r & ":E" & r)
'ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1" '删除本句前的'可将各个图表作为对象插入sheet1中,否则各图表将单独作为chart表插入工作簿。
Next
End Sub
===================
Sub 图表批量生成()
xx = 0
yy = 0
For r = 4 To 57 '以每位学生生成一个图表,循环产生全班每位学生的曲线图
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("一班全图").Range("A" & r & ":U" & r), PlotBy _
:=xlRows '源数据系列产生于行
ActiveChart.Location Where:=xlLocationAsObject,Name:="一班全图" '所有图表插入同一工作表中
With ActiveChart.Axes(xlValue) '设置图表属性 如:刻度和线型
.MinimumScaleIsAuto = True
.MaximumScale = 60
.MinorUnit = 1
.MajorUnit = 5
.Crosses = xlAutomatic
.ReversePlotOrder = True
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveChart.Legend.Select
Selection.Delete
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 3
.Weight = xlMedium
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = 5
.MarkerStyle = xlCircle
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With '图表属性设置结束
Set myDocument = ActiveSheet
For Each S In myDocument.ChartObjects
'MsgBox (S.Name)
S.Activate
ActiveChart.ChartArea.Select '设置图表(即外框)大小及在工作表中的位置
S.Top = yy * 136
S.Left = xx * 274
S.Height = 132
S.Width = 270
ActiveChart.PlotArea.Select '设置绘图区大小及相对于外框的位置
Selection.Top = 9
Selection.Height = 132
Selection.Left = 0
Selection.Width = 270
xx = xx + 1 '设置计数器,让图表每三个排一行
If xx >= 3 Then
xx = 0
yy = yy + 1
End If
Next S
Next r
End Sub
==================================
ActiveChart.ChartArea.Select
Sub 改变图表尺寸()
Set myDocument = ActiveSheet
For Each S In myDocument.ChartObjects
'MsgBox (S.Name)
S.Activate
ActiveChart.ChartArea.Select '这部分是图表区的尺寸代码
S.Width = 200
S.Height = 200
ActiveChart.PlotArea.Select '这部分是绘图区的尺寸代码
Selection.Width = 191
Selection.Top = 9
Selection.Height = 185
Next S
End Sub=================
清除图表可以用这个:
Sub test()
For Each r In Sheets("一班全图").ChartObjects
r.Delete
Next
End Sub
=========================
excel如何生成图表?
VBA自动生成图表的问题!
在Excel中用VBA编写一个程序
Excel VBA
Excel VBA
vba excel
excel中如何批量锁定生成的随机数?急~~~~
EXCEL中如何利用1个文件,生成批量文件
在Excel中用Vba写的程序如何做成可安装的应用程序
EXCEL中用VBA编程,如何在打印成PDF文件的时候自动给文件命名?
Excel图表
4:在Excel中,根据生成的图表所在位置的不同,可以将其分为( )和图表工作
VBA高手请进(怎样在打开的EXCEL工作表中用VBA读入另一个存在盘上的工作表的指定页面)?
excel VBA小问题
EXCEL VBA 问题
excel VBA教程电子书
Excel VBA 高手进
EXCEL VBA 基础教程下载
Excel VBA中EXCEL对象?
Excel放置图表方式
excel中图表是什么?
EXCEL图表问题
EXCEL图表问题
Excel图表问题