'--------------------------------------------------------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单台安装配置

    1.对设备的管理口进行配置 管理口的默认设置 •IP 地址: 192.168.1.245/24 2.用户名和密码 1)初始密码: 图形界面用户名/密码:admin/admin:命令行用户名/密码:ro ...

  2. Django的具体操作(一)

    一,首先说下什么是Django,Django其实就是一个框架,用python写的,能开发网站之类的. 二,django的组成 1,urls:网址入口关联到对应的views视图函数,(采用mvc开发模式 ...

  3. HW3 纠结的心得

    改好的controller //yuec2 Yue Cheng package hw3; import java.io.File; import java.text.DecimalFormat; im ...

  4. 从mysql导入及导出csv

    csv导入: load data local infile 'D:/pcode/shu/data/a.csv' into table a fields terminated by ','; csv导出 ...

  5. YII2中使用控制台命令

    有些时候我们需要通过crontab在后台跑一些定时脚本,这时候就需要用到控制台命令了. 我们在commands目录下创建TestController.php,当然脚本的位置是可以随意指定的,只需要在c ...

  6. git diff 分支1 分支2 --stat命令没有将所有的不同显示出来

    昨天遇到使用git diff 分支1 分支2  --stat命令时打印的文件修改列表,并不全,导致找了一下午的问题没有找到...特此记录,显示不全的原因我还没有找到,特此记录.

  7. vuex,文件夹整理

    不多说直接上图 1,执行事件和调用 2添加模块 3模块内执行过程

  8. js document.load 和 document.ready 区别

    document.ready和onload的区别——JavaScript文档加载完成事件 页面加载完成有两种事件 一是ready,表示文档结构已经加载完成(不包含图片等非文字媒体文件) 二是onloa ...

  9. Magento2 php商城在windows10上安装

    magento2 下载地址:https://github.com/magento/magento2/archive/develop.zip 参考地址: 版本要求 这个magento2  要选择好php ...

  10. Android.StructureOfAndroidSourceCodeRootTree

    Refference 1. How to understand the directory structure of android root tree? http://stackoverflow.c ...