EXCEL把连字符数据展开如何把“C1-C10”展为“C1,C2,C3...”

如何把“C1-C10”展为“C1,C2,C3...”
2025-01-07 17:55:44
推荐回答(1个)
回答1:

在SHEET1中的A1中输入 C1-C10,这个自己定到C50000也不是问题

运行下面宏

Public Sub A1TOX()
Dim ARR, i, i1, ii
Dim a(1) As Integer
Dim i2 As Integer
i1 = 0
ii = 1
ARR = Split(Sheet1.Range("A1"), "-")
For Each i In ARR
a(i1) = Mid(i, 2, Len(i) - 1)
i1 = i1 + 1
Next
For i2 = a(0) To a(1)
Sheet1.Cells(ii, 2) = Mid(Sheet1.Range("a1"), 1, 1) & i2
ii = ii + 1
Next
End Sub

效果如下
C1-C10 C1
C2
C3
C4
C5
C6
C7
C8
C9
C10