|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub test()
Dim arr, i, j, k, m
With Sheets("sheet1")
arr = .Range("a2:e" & .Cells(Rows.Count, "c").End(xlUp).Row + 1).Value
For i = 2 To UBound(arr, 1) - 1
If Len(arr(i, 1)) > Len(arr(i - 1, 1)) And Len(arr(i, 1)) > Len(arr(i + 1, 1)) Then
If Len(arr(i + 1, 1)) = 0 Then
For j = i + 1 To UBound(arr, 1) - 1
m = m + 1
arr(m, 1) = arr(i, 1): arr(m, 2) = arr(i, 2)
For k = 3 To UBound(arr, 2)
arr(m, k) = arr(j, k)
Next
If Len(arr(j + 1, 1)) > 0 Or j = UBound(arr, 1) - 1 Then i = j: Exit For
Next
Else
m = m + 1
For j = 1 To UBound(arr, 2)
arr(m, j) = arr(i, j)
Next
End If
End If
Next
End With
Sheets("实现效果").[a2].Resize(m, UBound(arr, 2)) = arr
End Sub |
评分
-
2
查看全部评分
-
|