好文档 - 专业文书写作范文服务资料分享网站

excel宏教程

天下 分享 时间: 加入收藏 我要投稿 点赞

Selection.Borders(<边线>).Weight =

XlBorderWeight(宽度值): xlHairline ?极细 xlThin ?细 xlMedium ?中等 xlThick ?粗

3. 设置边线的颜色

Selection.Borders(xlEdgeLeft).ColorIndex = <0到56之间的数字> Selection.Borders(xlEdgeLeft).Color =

十、 删除选中的单元格 Selection.Delete Selection.EntireRow.Delete Selection.EntireColumn.Delete

例:Selection.Delete Shift:=xlToLeft ?删除选中的单元格,并将已删除单元格所在位置右面的单元格向左移动

Selection.Delete Shift:=xlUp ?删除选中的单元格,并将已删除单元格所在位置下面的单元格向上移动

Selection.EntireRow.Delete ?删除选中单元格所在的行 Selection.EntireColumn.Delete ?删除选中单元格所在的列

十一、设置单元格背景色及图案 1. 背景色

Selection.Interior.ColorIndex = <0到56之间的数字> Selection.Interior.Color = 2. 图案样式

Selection.Interior.Pattern =

Constants(图案样式): xlSolid '实心 xlGray75 '75% 灰色 xlGray50 '50% 灰色 xlGray25 '25% 灰色 xlGray16 '12.5% 灰色 xlGray8 '6.25% 灰色 xlHorizontal '水平 条纹 xlVertical '垂直 条纹 xlDown '逆对角线 条纹 xlUp '对角线 条纹 xlChecker '对角线 剖面线 xlSemiGray75 '粗 对角线 剖面线 xlLightHorizontal '细 水平 条纹 xlLightVertical '细 垂直 条纹 xlLightDown '细 逆对角线 条纹 xlLightUp '细 对角线 条纹 xlGrid '细 水平 剖面线 xlCrissCross '细 对角线 剖面线

3. 图案颜色

Selection.Interior.PatternColorIndex = <0到56之间的数字> Selection.Interior.PatternColor =

十二、返回工作表中的行数

Sheet1.UsedRange.Rows.Count ?返回从最小已输入内容的行号到最大已输入内容的行号之间的行数

Sheet1.UsedRange.Rows(Sheet1.UsedRange.Rows.Count).Row ?最大已输入内容的行号

十三、得到当前EXCEL的文件名 ThisWorkbook.Path ?文件路径 ThisWorkbook.Name ?文件名 ThisWorkbook.FullName ?全路径

十四、批注的操作 1. 添加批注 AddComment([Content])

例:Range(\2. 修改批注内容 Comment.Text

例:Range(\3. 显示/隐藏批注

Comment.Visible = 4. 删除批注 ClearComments

例:Selection.Range(\5. 选中批注

Comment.Shape.Select True

例:Range(\6. 改变批注大小和位置

Selection.ShapeRange.ScaleWidth <宽度比例>, msoFalse, Selection.ShapeRange.ScaleHeight <高度比例>, msoFalse,

例:Selection.ShapeRange.ScaleWidth 1.5, msoFalse, msoScaleFromTopLeft ?每次增加5%的宽度

Selection.ShapeRange.ScaleHeight 0.6, msoFalse, msoScaleFromTopLeft ?每次减少6%的宽度

Selection.ShapeRange.Left = <左边距> Selection.ShapeRange.Top = <上边距> Selection.ShapeRange.Width = <宽度值> Selection.ShapeRange.Height = <高度值>

十五、剪切、复制、粘贴 Selection.Cut ?剪切

Selection.Copy ?复制 ActiveSheet.Paste ?粘贴

例:Range(\Selection.Cut

Range(\ActiveSheet.Paste Selection.Copy

Range(\ActiveSheet.Paste

十六、选择性粘贴

Selection.PasteSpecial

十七、改变列宽

Selection.ColumnWidth = <宽度值> ?指定列宽

例:Columns(\

Selection.ColumnWidth = 30 ?改变已选列的宽度

EntireColumn.AutoFit ?自动改变列宽

例:Columns(\?根据C列的内容自动改变列的宽度

excel宏教程

Selection.Borders().Weight=XlBorderWeight(宽度值):xlHairline?极细xlThin?细xlMedium?中等xlThick?粗3.设置边线的颜色Selection.Borders(xlEdg
推荐度:
点击下载文档文档为doc格式
7stbb1pjgn5dq8n1sb8p
领取福利

微信扫码领取福利

微信扫码分享