我输入了示例ABC100-10。意思是,它是一系列的:
ColA |
ABC100|
ABC101|
... |
ABC110|
如何将“ACB100-10”粘贴到单元格中,然后让Excel将其展开到ABC100,ABC101,...,ABC110中?我知道拖下来扩展..但我不想要这种方法:)
谢谢。
答案 0 :(得分:0)
如果您运行此宏,则将从ActiveCell中填充该列:
Sub KolumnKreator()
Dim s As String, K As Long, N As Long, T As String
s = Application.InputBox(Prompt:="Enter input", Type:=2)
If InStr(1, s, "-") = 0 Then Exit Sub
ary = Split(s, "-")
K = CLng(ary(1))
N = NumPart(ary(0))
T = TexPart(ary(0))
For i = 0 To K
ActiveCell.Offset(i, 0).Value = T & N + i
Next i
End Sub
Public Function NumPart(Inn) As Long
temp = ""
For i = 1 To Len(Inn)
ch = Mid(Inn, i, 1)
If ch Like "[0-9]" Then temp = temp & ch
Next i
NumPart = CLng(temp)
End Function
Public Function TexPart(Inn) As String
temp = ""
For i = 1 To Len(Inn)
ch = Mid(Inn, i, 1)
If Not ch Like "[0-9]" Then temp = temp & ch
Next i
TexPart = temp
End Function