'--------------------------------------------------------Module1--------------------------------------------------------
Sub Macro1()
ActiveSheet.Range("B1:B40").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Range("'Sheet1'!$A$1:$B$40")
With ActiveChart
.HasTitle = True '为图表设置标题
With .ChartTitle
.Text = "交会图版"
.Font.Name = "宋体"
.Font.Size =
.Font.ColorIndex =
.Top =
.Left =
End With
With .Axes(xlCategory) '为图表设置横坐标
.HasTitle = True
.AxisTitle.Text = "统计含量"
.AxisTitle.Font.Name = "宋体"
.AxisTitle.Font.Size =
.AxisTitle.Font.Bold = False
.AxisTitle.Font.ColorIndex =
.MinimumScale = Cells(, ) - Cells(, ) * 0.2
.MaximumScale = Cells(, ) + Cells(, ) * 0.2
End With With .Axes(xlValue) '为图表设置纵坐标
.HasTitle = True
.AxisTitle.Text = "百分数"
.AxisTitle.Font.Name = "宋体"
.AxisTitle.Font.Size =
.AxisTitle.Font.Bold = False
.AxisTitle.Font.ColorIndex =
' i = Excel.Application.WorksheetFunction.Match("203", f, 0)
.MinimumScale = Excel.Application.WorksheetFunction.Min(Range("B:B")) '**zbl**范围要加一个Range才不会出错,下面的不行
.MaximumScale = Excel.Application.WorksheetFunction.Max(Range("B:B"))
' .MinimumScale = Excel.Application.WorksheetFunction.Min("B:B")
' .MaximumScale = Excel.Application.WorksheetFunction.Max("B:B")
' .MinimumScale = Application.WorksheetFunction.Min("b1:b40")
' .MaximumScale = Application.WorksheetFunction.Max("b4:b40")
'Sub UseFunction()
' Dim myRange As Range
' Set myRange = Worksheets("Sheet1").Range("A1:C10")
' answer = Application.WorksheetFunction.Max搜索(myRange)
' MsgBox answer
'End Sub
End With
.HasLegend = True '为图表设置图例
With .Legend
.Position = xlLegendPositionRight
.Font.ColorIndex =
.Font.Bold = True
End With
End With End Sub

多个系列:

参考:http://club.excelhome.net/thread-1199400-1-1.html

 '--------------------------------------------------------Module1--------------------------------------------------------
Sub Macro1()
ActiveSheet.Range("B1:C40").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatterSmooth '平滑线散点图
ActiveChart.SetSourceData Source:=Range("'Sheet1'!$A$1:$C$40")
With ActiveChart
.HasTitle = True '为图表设置标题
.SeriesCollection().Name = "sin" '为图例设置名称
.SeriesCollection().Name = "cos" '.SeriesCollection(i).Name=Worksheets("Sheet1").Range("A" & i)
With .ChartTitle
.Text = "正弦余弦图"
.Font.Name = "宋体"
.Font.Size =
.Font.ColorIndex =
.Top =
.Left =
End With
With .Axes(xlCategory) '为图表设置横坐标
.HasTitle = True
.AxisTitle.Text = "统计含量"
.AxisTitle.Font.Name = "宋体"
.AxisTitle.Font.Size =
.AxisTitle.Font.Bold = False
.AxisTitle.Font.ColorIndex =
.MinimumScale = Cells(, ) - Cells(, ) * 0.2
.MaximumScale = Cells(, ) + Cells(, ) * 0.2
End With With .Axes(xlValue) '为图表设置纵坐标
.HasTitle = True
.AxisTitle.Text = "百分数"
.AxisTitle.Font.Name = "宋体"
.AxisTitle.Font.Size =
.AxisTitle.Font.Bold = False
.AxisTitle.Font.ColorIndex =
' i = Excel.Application.WorksheetFunction.Match("203", f, 0)
.MinimumScale = Excel.Application.WorksheetFunction.Min(Range("B:B")) '**zbl**范围要加一个Range才不会出错,下面的不行
.MaximumScale = Excel.Application.WorksheetFunction.Max(Range("B:B"))
' .MinimumScale = Excel.Application.WorksheetFunction.Min("B:B")
' .MaximumScale = Excel.Application.WorksheetFunction.Max("B:B")
' .MinimumScale = Application.WorksheetFunction.Min("b1:b40")
' .MaximumScale = Application.WorksheetFunction.Max("b4:b40")
'Sub UseFunction()
' Dim myRange As Range
' Set myRange = Worksheets("Sheet1").Range("A1:C10")
' answer = Application.WorksheetFunction.Max搜索(myRange)
' MsgBox answer
'End Sub
End With
.HasLegend = True '为图表设置图例
With .Legend
.Position = xlLegendPositionRight
.Font.ColorIndex =
.Font.Bold = True
End With End With End Sub

设置网格线:

 '--------------------------------------------------------Module1--------------------------------------------------------
Sub Macro1()
ActiveSheet.Range("B1:C40").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatterSmooth '平滑线散点图
ActiveChart.SetSourceData Source:=Range("'Sheet1'!$A$1:$C$40")
ActiveWindow.GridlineColor = RGB(, , ) '窗体excel网格周围的线成红色了
ActiveWindow.DisplayGridlines = False
With ActiveChart
.HasTitle = True '为图表设置标题
.SeriesCollection().Name = "sin" '为图例设置名称
.SeriesCollection().Name = "cos" '.SeriesCollection(i).Name=Worksheets("Sheet1").Range("A" & i)
With .ChartTitle
.Text = "正弦余弦图"
.Font.Name = "宋体"
.Font.Size =
.Font.ColorIndex =
.Top =
.Left =
End With
With .Axes(xlCategory) '为图表设置横坐标
.HasTitle = True
.AxisTitle.Text = "统计含量"
.AxisTitle.Font.Name = "宋体"
.AxisTitle.Font.Size =
.AxisTitle.Font.Bold = False
.AxisTitle.Font.ColorIndex =
.MinimumScale = Cells(, ) - Cells(, ) * 0.2
.MaximumScale = Cells(, ) + Cells(, ) * 0.2
End With With .Axes(xlValue) '为图表设置纵坐标
.HasTitle = True
.AxisTitle.Text = "百分数"
.AxisTitle.Font.Name = "宋体"
.AxisTitle.Font.Size =
.AxisTitle.Font.Bold = False
.AxisTitle.Font.ColorIndex =
' i = Excel.Application.WorksheetFunction.Match("203", f, 0)
.MinimumScale = Excel.Application.WorksheetFunction.Min(Range("B:B")) '**zbl**范围要加一个Range才不会出错,下面的不行
.MaximumScale = Excel.Application.WorksheetFunction.Max(Range("B:B"))
' .MinimumScale = Excel.Application.WorksheetFunction.Min("B:B")
' .MaximumScale = Excel.Application.WorksheetFunction.Max("B:B")
' .MinimumScale = Application.WorksheetFunction.Min("b1:b40")
' .MaximumScale = Application.WorksheetFunction.Max("b4:b40")
'Sub UseFunction()
' Dim myRange As Range
' Set myRange = Worksheets("Sheet1").Range("A1:C10")
' answer = Application.WorksheetFunction.Max搜索(myRange)
' MsgBox answer
'End Sub
End With
.HasLegend = True '为图表设置图例
With .Legend
.Position = xlLegendPositionRight
.Font.ColorIndex =
.Font.Bold = True
End With
Range("c1:d2").Borders.LineStyle = xlContinuous '区域全部设置线
Range("c1:d2").Borders.LineStyle = xlNone '取消单元格线’
Range("d4").Borders(xlEdgeTop).LineStyle = xlContinuous '只设置单元格d3顶线 http://www.excelpx.com/thread-294531-1-1.html With Range("a1:b2").Borders
.LineStyle = xlContinuous '设置边框线
.Weight = xlThick '设置边框线为粗线
End With End With End Sub

说明

每个 ChartObject 对象都代表一个嵌入图表。ChartObject 对象充当 Chart 对象的容器。ChartObject
对象的属性和方法控制工作表上嵌入图表的外观和大小。ChartObjects 集合

示例

使用 ChartObjects 方法返回 ChartObjects
集合。以下示例删除名为“Sheet1”的工作表上的所有嵌入图表。

Visual Basic for Applications
Worksheets("sheet1").ChartObjects.Delete

不能使用 ChartObjects 集合来调用以下属性和方法:

与早期版本不同,ChartObjects 集合现在可以读取有关高度、宽度、左对齐和顶对齐的属性。

使用 Add 方法可创建一个新的空嵌入图表并将它添加到集合中。使用 ChartWizard 方法可添加数据并设置新图表的格式。以下示例创建一个新嵌入图表,然后以折线图形式添加单元格 A1:A20 中的数据。

Visual Basic for Applications
Dim ch As ChartObject
Set ch = Worksheets("sheet1").ChartObjects.Add(100, 30, 400, 250)
ch.Chart.ChartWizard source:=Worksheets("sheet1").Range("a1:a20"), _
gallery:=xlLine, title:="New Chart"

使用 ChartObjects(index)(其中 index 是嵌入图表的索引号或名称)可以返回单个对象。以下示例设置名为“Sheet1”的工作表上嵌入图表 Chart 1 中的图表区图案。

Visual Basic for Applications
Worksheets("Sheet1").ChartObjects(1).Chart. _
CChartObjecthartArea.Format.Fill.Pattern = msoPatternLightDownwardDiagonal
 Dim ch As ChartObject
Set ch = Worksheets("sheet1").ChartObjects.Add(, , , )
ch.Chart.ChartWizard source:=Worksheets("sheet1").Range("a1:a20"), _
gallery:=xlLine, title:="New Chart"

excel2007VBA绘图2的更多相关文章

  1. excel2007vba绘图1

    参考:http://club.excelhome.net/thread-480025-1-1.html '----------------------------------------------- ...

  2. Canvas绘图之平移translate、旋转rotate、缩放scale

    画布操作介绍 画布绘图的环境通过translate(),scale(),rotate(), setTransform()和transform()来改变,它们会对画布的变换矩阵产生影响. 函数 方法 描 ...

  3. 用html5的canvas和JavaScript创建一个绘图程序

    本文将引导你使用canvas和JavaScript创建一个简单的绘图程序. 创建canvas元素 首先准备容器Canvas元素,接下来所有的事情都会在JavaScript里面. <canvas ...

  4. echarts+php+mysql 绘图实例

    最近在学习php+mysql,因为之前画图表都是直接在echart的实例demo中修改数据,便想着两相结合练习一下,通过ajax调用后台数据画图表. 我使用的是echart3,相比较第二版,echar ...

  5. html5 canvas常用api总结(二)--绘图API

    canvas可以绘制出很多奇妙的样式和美丽的效果,通过几个简单的api就可以在画布上呈现出千变万化的效果,还可以制作网页游戏,接下来就总结一下和绘图有关的API. 绘画的时候canvas相当于画布,而 ...

  6. HTML5_04之SVG绘图

    1.关于Canvas绘制图像: 问题:需要绘制多张图片时,必须等待所有图片加载完成才能开始绘制:而每张图片都是异步请求,彼此没有先后顺序,哪一张先加载完成完全无法预测: 方案: var progres ...

  7. HTML5 学习总结(四)——canvas绘图、WebGL、SVG

    一.Canvas canvas是HTML5中新增一个HTML5标签与操作canvas的javascript API,它可以实现在网页中完成动态的2D与3D图像技术.<canvas> 标记和 ...

  8. AR创意分享:儿童涂鸦遇上程序绘图

    第一节 临摹 小明经常临摹同桌小美的画作. 美术课上,老师表扬了小美的新作. 图1.1 小美的作品<蒙娜·毛虫的微笑> 临,是照着原作画:摹,是用薄纸张蒙在原作上面画. 第二节 借画 小明 ...

  9. C# 一段绘图代码 在form_load事件不能显示图

    今天无意将一段绘图代码 写在form_load事件了,结果不能显示绘图.(代码:Graphics g = this.CreateGraphics();Pen pen = new Pen(Color.R ...

随机推荐

  1. f5 Seldom used

    1.负载均衡算法 2)最快响应速度(Fastest) •优先查看7层请求的连接数,然后查看4层连接数 •需要在virtual server上关联7层的profile,否则与最小连接数相同 •后台服务器 ...

  2. [BX]指令

    mov ax,[bx] 功能:bx中存放的数据作为一个偏移地址EA,段地址SA默认在ds中,将SA:EA处的数据送入ax中.即(ax)=((ds)*16+(bx)). mov [bx],ax 功能:b ...

  3. Requested a new session but one was in progress

    作为appium初学者,估计很多人都会遇到这个错误.如何解决: 1.环境变量中去掉appium的安装路径,添加Appium\node_modules\.bin这个路径进去. 2.启动cmd 输入app ...

  4. Javascript 四种输出方式

    JavaScript 输出 javascript 没有任何打印或输出的函数 可以通过不同的方式输出数据 使用window.alert() 弹出警告框 使用document.write()方法将内容写到 ...

  5. Java中的forin语句

    forin的原理 forin语句是JDK5版本的新特性,在此之前,遍历数组或集合的方法有两种:通过下标遍历和通过迭代器遍历.先举个例子: @Test public void demo() { Stri ...

  6. js filter关键字

    filter filter也是一个常用的操作,它用于把Array的某些元素过滤掉,然后返回剩下的元素. 和map()类似,Array的filter()也接收一个函数.和map()不同的是,filter ...

  7. 函数调用的四种方式 和 相关的 --- this指向

    this:表示被调用函数的上下文对象. arguments:表示函数调用过程中传递的所有参数. 这两个参数都是隐式的函数参数.会静默传递给函数,并且和函数体内显式声明的参数一样可正常访问. argum ...

  8. BZOJ1912或洛谷3629 [APIO2010]巡逻

    一道树的直径 BZOJ原题链接 洛谷原题链接 显然在原图上路线的总长为\(2(n-1)\). 添加第一条边时,显然会形成一个环,而这条环上的所有边全部只需要走一遍.所以为了使添加的边的贡献最大化,我们 ...

  9. APP强制退出

    第一种方法: 企业版可以用,Appstore可能被拒,慎用 - (void)exitApplication { AppDelegate *app = [UIApplication sharedAppl ...

  10. unbutton 内部title label多行显示

    dateBtn1.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; [dateBtn1 setTitle: @第一行\n第二行" f ...