求助:输入行号,即将该行文本形式转化为数字形式,VBA代码怎么写。
Sub macro1()
Dim irow, n%
irow = InputBox("请输入需要转化的那一行的行号。")
If irow = "" Then Exit Sub
On Error GoTo 100
n = 1: GoTo 200
100 MsgBox "输入行号错误,请重新开始。": Exit Sub
200
Do While Cells(irow, n) <> ""
Cells(irow, n).TextToColumns DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, _
TrailingMinusNumbers:=True
Cells(irow, n).NumberFormatLocal = "G/通用格式"
n = n + 1
Loop
End Sub
整行转换为数值格式-两位小数,并使用千分位及符号【可按需更改】
Sub转数字格式()i=InputBox("请输入行号:")Rows(i&":"&i).SelectSelection.NumberFormatLocal="#,##0.00_"Range("A"&i).SelectEndSub。
可以用转换器转换一下
热门标签: