VBA公式文本转换为数值.md 978 B

Sub 公式文本转换为数值()
Dim rng As Range
'Selection.SpecialCells(xlCellTypeVisible).Select '定位可见单元格,解决筛选情形的选区问题
'选择首报表
Sheets(1).Select
'选择A单元格区域数据
ActiveSheet.Range("A1").CurrentRegion.Select
For Each rng In Selection
If rng <> "" Then
rng.NumberFormatLocal = "G/通用格式" '单元格更改成常规格式
rng = rng.Value '转换为数值
End If
Next Sheets(2).Select
ActiveSheet.Range("A1").CurrentRegion.Select
For Each rng In Selection
If rng <> "" Then
rng.NumberFormatLocal = "G/通用格式" '单元格更改成常规格式
rng = rng.Value '转换为数值
End If
Next Sheets(3).Select
ActiveSheet.Range("A1").CurrentRegion.Select
For Each rng In Selection
If rng <> "" Then
rng.NumberFormatLocal = "G/通用格式" '单元格更改成常规格式
rng = rng.Value '转换为数值
End If
Next
'MsgBox "处理完毕!"
End Sub