Sub direct_Price()
''定义变量
Dim cRows As Integer '总行数
olumns As Integer '总列数
Dim HEADERCOLORINDEX As Integer '表头的背景色
Dim cTemp As Integer '临时计数
Dim sTempString As String '临时字符串变量
Dim i As Integer '临时计数
Dim j As Integer '临时计数
Dim rowIndex As Integer '临时指示处理到哪里
Dim colIndex As Integer '临时指示处理到哪里
Dim tempRndColor As Integer '临时生成的颜色
Dim TABLENAME As String '待处理的表名
Dim colorIndex As String '颜色索引名字
''''''''''''''''''''''''''''''''''''''''''''''
'表头的背景色
HEADERCOLORINDEX = 15
colorIndex = 36 '颜色从33开始是比较浅的颜色
TABLENAME = "direct_Price"
'关闭所有弹出的警告消息
= False
'设置需要处理的单元表
Sheets(TABLENAME).Select
'取单元表的总列数与总行数
cRows = Sheets(TABLENAME).
cColumns = Sheets(TABLENAME).
''''''''''''''''''''''''''''''''''''''''''''''
'选择所有的单元格
Range(Cells(1, 1), Cells(cRows, cColumns)).Select
'
=
'
=
'设置所有的边框
(xlDiagonalDown).LineStyle = xlNone
(xlDiagonalUp).LineStyle = xlNone
With (xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.colorIndex = xlAutomatic
End With
With (xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.colorIndex = xlAutomatic
End With
With (xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.colorIndex = xlAutomatic
End With
With (xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.colorIndex = xlAutomatic
End With
With (xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.colorIndex = xlAutomatic
End With
'并且拆分所有的单元格
With Selection
.MergeCells = False '拆分单格
End With
Columns("C:C").Se
VBA编程实例 来自淘豆网m.daumloan.com转载请标明出处.