怎样将excel中 1-9变为123456789?

对单元格中连续的数值,变为单个的数值
也就是说在单元格中将一个连续的数例如”12-16”,变为”12,13,14,15,16”.

第1个回答  推荐于2016-05-02
只好自定义一个函数啦
按下ALT+F11 插入-模块 输入
Public Function NTON(nTXT As String)
Dim nARR
Dim nStr As String
nARR = Split(nTXT, "-")
For i = nARR(0) To nARR(1)
nStr = nStr & i & ","
Next
NTON = nStr
End Function

然后就可以在表格中像其它函数一样用这个 NTON()了本回答被提问者采纳
第2个回答  2008-01-30
我是假设你这样的数据输入在A1,然后从B1开始横向填充.
按下ALT+F11,插入-模块,复制下代码,然后按F5运行.

Sub aaaa()
Dim a As Integer
Dim b As Integer
a = Val(Left(Cells(1, 1), WorksheetFunction.Find("-", Cells(1, 1)) - 1))
b = Val(Right(Cells(1, 1), Len(Cells(1, 1)) - WorksheetFunction.Find("-", Cells(1, 1))))
Range("b1").Select
For x = a To b
ActiveCell.Value = x
ActiveCell.Offset(0, 1).Select
Next
End Sub

****************
这个是在同一单元格B1中体现

Sub aaaa()
Dim a As String
Dim b As String
Dim sum As String
a = Left(Cells(1, 1), WorksheetFunction.Find("-", Cells(1, 1)) - 1)
b = Right(Cells(1, 1), Len(Cells(1, 1)) - WorksheetFunction.Find("-", Cells(1, 1)))
For x = a To b
sum = sum & x & ","
Next
Range("b1").Select
ActiveCell.Value = sum
End Sub
第3个回答  2008-01-30
问题问的不是很清楚,你试试讲个单元格改成文本格式。
步骤:右击所要改的单元格-设置单元格格式-数字-文本
试试吧!
第4个回答  2008-01-30
搞不明白,替换:1-9为123456789吗?
就用替换菜单了
第5个回答  2008-01-30
问题不明确
相似回答