|
本帖最后由 gwjkkkkk 于 2022-12-14 21:44 编辑
Sub TEST()
Dim arr, vData, i&, j&, iPosRow, iRowSize&
arr = [C2].CurrentRegion
ReDim vData(1 To UBound(arr) * 1000, 1 To 2)
For j = 1 To UBound(arr, 2)
iPosRow = 0
For i = 2 To UBound(arr)
If arr(i, j) <> "" Then
arr(i, j) = Replace(arr(i, j), "--", "-")
If InStr(arr(i, j), "-") Then
brr = Split(arr(i, j), "-")
For k = Val(brr(0)) To Val(brr(1))
iPosRow = iPosRow + 1
vData(iPosRow, j) = k
Next k
Else
iPosRow = iPosRow + 1
vData(iPosRow, j) = arr(i, j)
End If
End If
Next i
If iPosRow > iRowSize Then iRowSize = iPosRow
Next j
[F2].CurrentRegion.Offset(1).Clear
[F3].Resize(iRowSize, 2) = vData
With [F2].CurrentRegion
.Rows(1).Interior.Color = vbYellow
.HorizontalAlignment = xlCenter
.Borders.LineStyle = xlContinuous
.EntireColumn.AutoFit
.EntireRow.AutoFit
End With
Beep
End Sub
|
|