|
▼シェバルブラン さん:
A 列 又 出力はD列とします。適宜変更して下さい。
>番号
>A143
>A144
>A145
>A146〜A147
>A149
>A153
>A156〜A159
>A160
>A161〜A163
>A165
Sub TESTa()
Dim v As Variant
Dim i As Long
Dim j As Long
Dim k As Long
Dim d1() As Variant
Dim a As Variant
Dim n1 As Long
Dim n2 As Long
With Worksheets("Sheet1").Range("A1").CurrentRegion
v = .Offset(1).Resize(.Rows.Count - 1).Value
End With
For i = 1 To UBound(v)
a = Split(v(i, 1), "〜")
If UBound(a) = 0 Then
ReDim Preserve d1(j)
d1(j) = v(i, 1)
j = j + 1
Else
n1 = StrReverse(Val(StrReverse(a(0))))
n2 = StrReverse(Val(StrReverse(a(1))))
k = j
For j = j To j + n2 - n1
ReDim Preserve d1(j)
d1(j) = Left(a(1), Len(a(1)) - Len(CStr(n2))) & n1
n1 = n1 + 1
Next
End If
Next
' 出力先 変更して
With Worksheets("Sheet1")
.Columns(4).ClearContents
.Range("D1").Value = .Range("A1").Value
.Range("D2").Resize(j).Value = Application.Transpose(d1)
End With
End Sub
|
|