答案 0 :(得分:0)
假设地址以街道号开头,后跟空格,然后是地址的其余部分,以下内容应该会有所帮助。
Sub Demo()
Dim ws As Worksheet
Dim i As Long
Set ws = ThisWorkbook.Sheets("Sheet1") 'change Sheet1 to your data sheet
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
With ws
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row 'get last row in Column A
For i = 2 To lastrow
.Range("B" & i).Formula = Evaluate("=SUBSTITUTE(A" & i & ","" "","", "",1)")
Next i
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
答案 1 :(得分:0)
您可以循环遍历H列,并使用vba例程在每个单元格中用逗号替换第一个空格。
Sub Addcomma()
Dim i As Integer
With ActiveSheet
For i = 2 To .Cells(.Rows.Count, "H").End(xlUp).Row
.Cells(i, 8) = Replace(.Cells(i, 8), " ", ",", , 1)
Next
End With
End Sub
之后,您可以使用文本到列功能,使用逗号作为分隔符。