欢迎来到天天文库
浏览记录
ID:37923441
大小:107.00 KB
页数:17页
时间:2019-06-02
《Excel VBA编程实例》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Subdirect_Price()''定义变量DimcRowsAsInteger'总行数DimcColumnsAsInteger'总列数DimHEADERCOLORINDEXAsInteger'表头的背景色DimcTempAsInteger'临时计数DimsTempStringAsString'临时字符串变量DimiAsInteger'临时计数DimjAsInteger'临时计数DimrowIndexAsInteger'临时指示处理到哪里DimcolIndexAsInteger'临时指示处理到哪里DimtempRndColorAsInteger'
2、临时生成的颜色DimTABLENAMEAsString'待处理的表名DimcolorIndexAsString'颜色索引名字'表头的背景色HEADERCOLORINDEX=15colorIndex=36'颜色从33开始是比较浅的颜色TABLENAME="direct_Price"'关闭所有弹出的警告消息Application.DisplayAlerts=False'设置需要处理的单元表Sheets(TABLENAME).Select'取单元表的总列数与总行数cRows=Sheets(TABLENAME).UsedRange.Rows.Countc
3、Columns=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.Borders(xlDiag
4、onalUp).LineStyle=xlNoneWithSelection.Borders(xlEdgeLeft).LineStyle=xlContinuous.Weight=xlThin.colorIndex=xlAutomaticEndWithWithSelection.Borders(xlEdgeTop).LineStyle=xlContinuous.Weight=xlThin.colorIndex=xlAutomaticEndWithWithSelection.Borders(xlEdgeBottom).LineStyle=xlConti
5、nuous.Weight=xlThin.colorIndex=xlAutomaticEndWithWithSelection.Borders(xlEdgeRight).LineStyle=xlContinuous.Weight=xlThin.colorIndex=xlAutomaticEndWithWithSelection.Borders(xlInsideVertical).LineStyle=xlContinuous.Weight=xlThin.colorIndex=xlAutomaticEndWith'并且拆分所有的单元格WithSelec
6、tion.MergeCells=False'拆分单格EndWithColumns("C:C").SelectSelection.InsertShift:=xlToRight'删除第一列,注意这里必须先拆分单格,再删除第一列,否则一次就会把合并单元格所在列全部删除Range(Cells(1,1),Cells(1,1)).SelectSelection.EntireColumn.Delete'Selection.EntireColumn.Delete'向表头添加一行Rows("1:1").SelectSelection.InsertColumns("
7、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:F").SelectSelection.ColumnWidth=12.2
8、9'''''设定单元格A1:A2'''合并A1:A2单元格Range("A1:A2").Select'将数据写回WithSelectio
此文档下载收益归作者所有