欢迎来到天天文库
浏览记录
ID:49710824
大小:99.50 KB
页数:17页
时间:2020-03-03
《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'将数
此文档下载收益归作者所有