ExcelVBA编程实例.doc

ExcelVBA编程实例.doc

ID:49710824

大小:99.50 KB

页数:17页

时间:2020-03-03

ExcelVBA编程实例.doc_第1页
ExcelVBA编程实例.doc_第2页
ExcelVBA编程实例.doc_第3页
ExcelVBA编程实例.doc_第4页
ExcelVBA编程实例.doc_第5页
资源描述:

《ExcelVBA编程实例.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、.Subdirect_Price()''定义变量DimcRowsAsInteger'总行数DimcColumnsAsInteger'总列数DimHEADERCOLORINDEXAsInteger'表头的背景色DimcTempAsInteger'临时计数DimsTempStringAsString'临时字符串变量DimiAsInteger'临时计数DimjAsInteger'临时计数DimrowIndexAsInteger'临时指示处理到哪里DimcolIndexAsInteger'临时指示处理到哪里DimtempRndColorAsInte

2、ger'临时生成的颜色DimTABLENAMEAsString'待处理的表名DimcolorIndexAsString'颜色索引名字'表头的背景色HEADERCOLORINDEX=15colorIndex=36'颜色从33开始是比较浅的颜色TABLENAME="direct_Price"'关闭所有弹出的警告消息Application.DisplayAlerts=False'设置需要处理的单元表Sheets(TABLENAME).Select'取单元表的总列数与总行数cRows=Sheets(TABLENAME).UsedRange.Rows

3、.CountcColumns=Sheets(TABLENAME).UsedRange.Columns.Count'''''选择所有的单元格Range(Cells(1,1),Cells(cRows,cColumns)).Select'设置该表中所有单元行高为11.25Selection.RowHeight=11.25'设置该表中所有单元行高为11.25Selection.RowHeight=11.25'设置所有的边框Selection.Borders(xlDiagonalDown).LineStyle=xlNoneSelection.Bord

4、ers(xlDiagonalUp).LineStyle=xlNoneWord资料.WithSelection.Borders(xlEdgeLeft).LineStyle=xlContinuous.Weight=xlThin.colorIndex=xlAutomaticEndWithWithSelection.Borders(xlEdgeTop).LineStyle=xlContinuous.Weight=xlThin.colorIndex=xlAutomaticEndWithWithSelection.Borders(xlEdgeBotto

5、m).LineStyle=xlContinuous.Weight=xlThin.colorIndex=xlAutomaticEndWithWithSelection.Borders(xlEdgeRight).LineStyle=xlContinuous.Weight=xlThin.colorIndex=xlAutomaticEndWithWithSelection.Borders(xlInsideVertical).LineStyle=xlContinuous.Weight=xlThin.colorIndex=xlAutomaticEndW

6、ith'并且拆分所有的单元格WithSelection.MergeCells=False'拆分单格EndWithColumns("C:C").SelectSelection.InsertShift:=xlToRight'删除第一列,注意这里必须先拆分单格,再删除第一列,否则一次就会把合并单元格所在列全部删除Range(Cells(1,1),Cells(1,1)).SelectSelection.EntireColumn.Delete'Selection.EntireColumn.Delete'向表头添加一行Rows("1:1").Selec

7、tSelection.InsertWord资料.Columns("A:A").SelectSelection.ColumnWidth=9.29Columns("B:B").SelectSelection.ColumnWidth=6.71Columns("C:C").SelectSelection.ColumnWidth=15.29Columns("D:D").SelectSelection.ColumnWidth=29.86Columns("E:E").SelectSelection.ColumnWidth=12.29Columns("F:

8、F").SelectSelection.ColumnWidth=12.29'''''设定单元格A1:A2'''合并A1:A2单元格Range("A1:A2").Select'将数

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。