如何在没有公式的情况下为60,000个联系人添加逗号

时间:2017-08-26 07:17:52

标签: excel

如何在60k联系人中添加没有公式的逗号。我需要将街道号码与街道名称分开。我很难手动完成它。我把逗号放到地址后,我将它们分隔在列中。就像这样

https://i.stack.imgur.com/5b3B2.jpg https://i.stack.imgur.com/ARSdd.jpg

2 个答案:

答案 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

enter image description here

答案 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

之后,您可以使用文本到列功能,使用逗号作为分隔符。