Excel 宏处理随笔

Posted 95mz

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Excel 宏处理随笔相关的知识,希望对你有一定的参考价值。

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

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 宏处理随笔的主要内容,如果未能解决你的问题,请参考以下文章

Excel中使用宏工具,告别重复工作,批量处理xls文件 - WPS Excel

调用Excel宏批量处理文件

怎么样让Excel在打开时就自动执行编好的宏代码?

VB 宏+mysql解决EXCEL表格实现自动化处理

在Excel VBA中双击执行宏

WPS增加正则处理函数,简直如虎添翼