Option Explicit
Sub TEST6()
Dim ar, br, i&, strJoin1$, strJoin2$, isFlag As Boolean
Application.ScreenUpdating = False
ar = Range("A1", Cells(Rows.Count, "B").End(xlUp)).Value
ReDim br(1 To UBound(ar), 0): br(1, 0) = "地址"
For i = 2 To UBound(ar)
If Right(ar(i, 1), 4) = "0000" Then
strJoin1 = Replace(ar(i, 2), " ", ""): br(i, 0) = strJoin1
isFlag = True
ElseIf Right(ar(i, 1), 2) = "00" Then
strJoin2 = strJoin1 & Trim(ar(i, 2)): br(i, 0) = strJoin2
isFlag = False
Else
If isFlag Then
br(i, 0) = strJoin1 & Replace(ar(i, 2), " ", "")
Else
br(i, 0) = strJoin2 & Replace(ar(i, 2), " ", "")
End If
End If
Next i
Columns("D").Clear
[D1].Resize(UBound(br)) = br
Application.ScreenUpdating = True
Beep
End Sub
|