码迷,mamicode.com
首页 > 其他好文 > 详细

Excel 宏处理随笔

时间:2018-01-28 18:19:01      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:div   auto   body   style   vertica   ldo   diagonal   value   get   

 #将指定单元格内的数字文本转为数字

Sub 自动替换格式()

 


Dim nRow%‘定义一个名为nRow的变量
nRow = Range("a1048576").End(xlUp).Row ‘获得数据最后的行号

Range("a2:j" & nRow).Select‘选定指定范围内的单元格
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With

Range("h2:j" & nRow).Select
For Each xCell In Selection
xCell.Value = xCell.Value
Next xCell

End Sub

Excel 宏处理随笔

标签:div   auto   body   style   vertica   ldo   diagonal   value   get   

原文地址:https://www.cnblogs.com/95mz/p/8371622.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!